Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

JSON Parsing in BB10

Dears,

 

I want to know how to parse json in BlackBerry 10 .

 

Thanks.

Retired
rsarmentopeixoto
Posts: 16
Registered: ‎04-04-2013
My Device: Z10

Re: JSON Parsing in BB10

If you are using Cascades, you can check this documentation: https://developer.blackberry.com/cascades/documentation/device_platform/data_access/working_with_jso...

 

Best regards,

Rodrigo Peixoto

Developer
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

Re: JSON Parsing in BB10

i have QByteArray  that contain the json data 

how can i parse it 

the page you posted not clear for me .

Retired
rsarmentopeixoto
Posts: 16
Registered: ‎04-04-2013
My Device: Z10

Re: JSON Parsing in BB10

Try this one: https://developer.blackberry.com/cascades/files/release/samples/platform/jsonreadwrite.zip

This is a sample that shows how to do this.

Best regards,
Rodrigo Peixoto
Developer
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

Re: JSON Parsing in BB10

i traced this code before but i found it return String fom the json 

i need to get Vector or map from the json to use it in another place .

 

 

Retired
rsarmentopeixoto
Posts: 16
Registered: ‎04-04-2013
My Device: Z10

Re: JSON Parsing in BB10

This method (https://developer.blackberry.com/cascades/reference/bb__data__jsondataaccess.html#function-loadfromb... will return a QVariant that contains a map.

Best regards,
Rodrigo Peixoto
Developer
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

Re: JSON Parsing in BB10

thanks for your help 

 

now i parsed this json array 

("[{\"msg\":\"teto_1\"},{\"msg\":\"teto_2\"}]")

 

using 

QVariantList list = jda.loadFromBuffer(mJsonData).value<QVariantList>();

 but what can i do i have only jsonobject like :

("{\"msg\":\"teto_1\"}")

 how can i parse it ??

Developer
sho3ebovich
Posts: 120
Registered: ‎12-22-2011
My Device: ---

Re: JSON Parsing in BB10

[ Edited ]

finally i did it 

 

using 

QVariant mainList = jda.loadFromBuffer(mJsonData);
qDebug() << mainList.toMap().value("msg");

 

really thank you