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 <[email protected]> wrote: > 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 you are working in the product-apim, you can add the followin > to your pom file, > <groupId>org.wso2.carbon.apimgt</groupId> > <artifactId>org.wso2.carbon.apimgt.ballerina.native</artifactId> > as a new dependency, and you should be able to use the above method as > usual. > > Reagards. > > On Mon, Oct 30, 2017 at 6:02 PM, Gayan Chamara <[email protected]> wrote: > >> 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 = messages:getJsonPayload(m); >> >> Thanks, >> Gayan. >> >> >> On Mon, Oct 30, 2017 at 5:40 PM, Anupama Pathirage <[email protected]> >> wrote: >> >>> 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 s2 = jsons:toString(jsonVal); >>> system:println(s2); >>> } >>> >>> Thanks, >>> >>> Anupama >>> >>> >>> >>> On Mon, Oct 30, 2017 at 5:07 PM, Gayan Chamara <[email protected]> wrote: >>> >>>> 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 at 4:57 PM, Suthagar Kailayapathy < >>>> [email protected]> wrote: >>>> >>>>> 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 = <json> s; >>>>> >>>>> Thanks. >>>>> >>>>> On Mon, Oct 30, 2017 at 4:39 PM, Gayan Chamara <[email protected]> >>>>> wrote: >>>>> >>>>>> 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: [email protected] <[email protected]> * >>>>>> *Mobile : **+94 71 728 5827 <+94%2071%20728%205827>* >>>>>> <http://wso2.com/signature> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> >>>>> *K.Suthagar* >>>>> Software Engineering Intern | WSO2 >>>>> LinkedIn: https://www.linkedin.com/in/ksuthagar >>>>> <http://suthagar.inncaps.com/> >>>>> >>>>> Email: [email protected] >>>>> Mobile : +94779543968 <+94%2077%20954%203968> >>>>> Web: http://wso2.com >>>>> >>>>> >>>> >>>> >>>> -- >>>> Regards, >>>> >>>> *Gayan Chamara* >>>> >>>> *Software Engineering Intern* >>>> *WSO2 Inc.* >>>> >>>> >>>> *Email: [email protected] <[email protected]> * >>>> *Mobile : **+94 71 728 5827 <+94%2071%20728%205827>* >>>> <http://wso2.com/signature> >>>> >>> >>> >>> >>> -- >>> Anupama Pathirage >>> Technical Lead >>> WSO2, Inc. http://wso2.com/ >>> Email: [email protected] >>> Blog: http://mycodeideas.blogspot.com >>> Mobile:+94 71 8273 979 >>> >>> >>> >>> >> >> >> -- >> Regards, >> >> *Gayan Chamara* >> >> *Software Engineering Intern* >> *WSO2 Inc.* >> >> >> *Email: [email protected] <[email protected]> * >> *Mobile : **+94 71 728 5827 <+94%2071%20728%205827>* >> <http://wso2.com/signature> >> > > > > -- > *Sabeena Kumarawadu* | Software Engineering Intern > WSO2 Lanka (Pvt) Ltd. > #20, Palm Grove, Colombo 03, Sri Lanka > <https://maps.google.com/?q=20,+Palm+Grove,+Colombo+03,+Sri+Lanka&entry=gmail&source=g> > Mobile: +94 71 0372856 <+94%2071%20037%202856> > Email: [email protected] > [image: http://wso2.com/signature] <http://wso2.com/signature> > > -- Regards, *Gayan Chamara* *Software Engineering Intern* *WSO2 Inc.* *Email: [email protected] <[email protected]> * *Mobile : **+94 71 728 5827* <http://wso2.com/signature>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
