convert json string to arraylist in royale

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

convert json string to arraylist in royale

choirul anam
I have function in my php that return json string like this:

[{"0":"145","id":"145","1":"1-2016-005","kode":"1-2016-005","2":"1-2016-005
(CULZEAN)","keterangan":"1-2016-005 (CULZEAN)"},
{"0":"132","id":"132","1":"1-2016-006A","kode":"1-2016-006A","2":"1-2016-006A
(SMOP)","keterangan":"1-2016-006A (SMOP)"},
{"0":"126","id":"126","1":"1-2016-006","kode":"1-2016-006","2":"1-2016-006
(SMOP)","keterangan":"1-2016-006 (SMOP)"}]

i can decode that json to arraycollection in flex using:

var rawData:String=event.result.toString();//return above json string
var arr:Array=(com.adobe.serialization.json.JSON.decode(rawData) as Array);

How do i achieve this in apache royale ? how to decode that json string ?

Regards,
Choirul



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: convert json string to arraylist in royale

Piotr Zarzycki
Hi Choirul,

I think JSON.parse(json); would do for you that job. It's available in Royale. 

Thanks,
Piotr

wt., 9 kwi 2019 o 11:52 choirul anam <[hidden email]> napisał(a):
I have function in my php that return json string like this:

[{"0":"145","id":"145","1":"1-2016-005","kode":"1-2016-005","2":"1-2016-005
(CULZEAN)","keterangan":"1-2016-005 (CULZEAN)"},
{"0":"132","id":"132","1":"1-2016-006A","kode":"1-2016-006A","2":"1-2016-006A
(SMOP)","keterangan":"1-2016-006A (SMOP)"},
{"0":"126","id":"126","1":"1-2016-006","kode":"1-2016-006","2":"1-2016-006
(SMOP)","keterangan":"1-2016-006 (SMOP)"}]

i can decode that json to arraycollection in flex using:

var rawData:String=event.result.toString();//return above json string
var arr:Array=(com.adobe.serialization.json.JSON.decode(rawData) as Array);

How do i achieve this in apache royale ? how to decode that json string ?

Regards,
Choirul



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/


--

Piotr Zarzycki 

Patreon: https://www.patreon.com/piotrzarzycki

Reply | Threaded
Open this post in threaded view
|

Re: convert json string to arraylist in royale

choirul anam
Thanks, it works :)



--
Sent from: http://apache-royale-users.20374.n8.nabble.com/