Re: [Dev] String to JSON in Ballerina 0.89

2017-10-31 Thread Gayan Chamara
Hi Rajith & Suthagar, I tried the suggested method, but no luck. It gives the following error message, *incompatible types: 'string' cannot be converted to 'json'* I'm restricted to ballerina 0.89 because API Manager has not moved to a newer version yet. Regards, Gayan. On Mon, Oct 30, 2017

Re: [Dev] String to JSON in Ballerina 0.89

2017-10-31 Thread Gayan Chamara
Hi Sabeena, I'm working on carbon-apimgt. Thanks for the mail. That's the solution I was looking for. Regards, Gayan. On Tue, Oct 31, 2017 at 9:44 AM, Sabeena Kumrawadu wrote: > Hello Gayan, > > Do you work in the carbon-apimgt or the product-apim?? > > If you are working in

Re: [Dev] String to JSON in Ballerina 0.89

2017-10-31 Thread Gayan Chamara
Hi Anupama, Unfortunately, that too does not seem to work. Ballerina throws an error when I try to use *jsonVal.ab* or *jsonVal["ab"]*. However, I've come up with the following code and it seems to work. That'll do for now. message m = {}; messages:setStringPayload(m, str); json j =

Re: [Dev] String to JSON in Ballerina 0.89

2017-10-30 Thread Sabeena Kumrawadu
Hello Gayan, Do you work in the carbon-apimgt or the product-apim?? If you are working in the carbon-apimgt, there is a already written native function for this, (since ballerina 0.89 does not support this operation). Here is an example, json jsonObject = util:parse(stringObject); In case if

Re: [Dev] String to JSON in Ballerina 0.89

2017-10-30 Thread Suthagar Kailayapathy
Hi Gayan, Can you please take a look at here(last one), https://groups.google.com/forum/#!topic/ballerina-dev/DIWQIULUvSw string s = "somejson"; json j; Error e; j, err = s; Thanks. On Mon, Oct 30, 2017 at 4:39 PM, Gayan Chamara wrote: > Hi, > Is there a way to convert

Re: [Dev] String to JSON in Ballerina 0.89

2017-10-30 Thread Anupama Pathirage
Hi, In earlier versions of ballerina following should work for string to json and json to string conversions. import ballerina.lang.system; import ballerina.lang.jsons; function main(string[] args) { string s1 = "{'ab':'ddd'}"; json jsonVal = s1; system:println(jsonVal); string

Re: [Dev] String to JSON in Ballerina 0.89

2017-10-30 Thread Rajith Vitharana
Hi Gayan, You can use conversion syntax() to achieve this. Ex - function main(string[] args) { string ss = "{'ab':'ddd'}"; json jsonVal; jsonVal, _ = ss; println(jsonVal); } Thanks, On 30 October 2017 at 16:39, Gayan Chamara wrote: > Hi, >

[Dev] String to JSON in Ballerina 0.89

2017-10-30 Thread Gayan Chamara
Hi, Is there a way to convert JSON string into ballerina json type in ballerina 0.89? I couldn't find a suitable method in the docs. Thanks, Gayan. -- Regards, *Gayan Chamara* *Software Engineering Intern* *WSO2 Inc.* *Email: gaya...@wso2.com * *Mobile : **+94 71 728