Hi, using websocket, my client recevie this :
var data =
{"c2dictionary":true,
"data":{
"contenu":{
"0":{"id":1,"what":"rock","qt":1,"owner_id":59,"screen_x":202,"screen_y":314},
"1":{"id":2,"what":"rock","qt":1,"owner_id":59,"screen_x":202,"screen_y":314},
"2":{"id":3,"what":"rock","qt":1,"owner_id":59,"screen_x":516,"screen_y":373},
"3":{"id":4,"what":"rock","qt":1,"owner_id":59,"screen_x":639,"screen_y":287}},
"return":"load_objects_return"
}}
It works very good. I can see the whole JSON string in console. I used to load my json message into a dictionnary (called jmessage) so it's very convenient to reach data.
In that case I do :
Jmessage : Load JSON from string data
then :
jmessage.get("return")
is correct with "load_object_return" as value. But jmessage.get("contenu") is supposed to contain the object list :
:{
"0":{"id":1,"what":"rock","qt":1,"owner_id":59,"screen_x":202,"screen_y":314},
"1":{"id":2,"what":"rock","qt":1,"owner_id":59,"screen_x":202,"screen_y":314},
"2":{"id":3,"what":"rock","qt":1,"owner_id":59,"screen_x":516,"screen_y":373},
"3":{"id":4,"what":"rock","qt":1,"owner_id":59,"screen_x":639,"screen_y":287}}
but it returns 0. I believe that's because a dictionnary can not contain a object list as a value.
So how can I do to retrieve the object list from the original string data ?
UPDATE : I realize the nested data wasn't at the C2 dictionary format. So I changed the string like this :
{"c2dictionary":true,"data":{"contenu":{"c2dictionary":true,"data":{"0":{"id":1,"what":"rock","qt":1,"owner_id":59,"screen_x":202,"screen_y":314},"1":{"id":2,"what":"rock","qt":1,"owner_id":59,"screen_x":202,"screen_y":314},"2":{"id":3,"what":"rock","qt":1,"owner_id":59,"screen_x":516,"screen_y":373},"3":{"id":4,"what":"rock","qt":1,"owner_id":59,"screen_x":639,"screen_y":287}}},"return":"load_objects_return"}}
So I can load jmessage.get("contenu") as a dictionnary. But this one remains empty from data. Because it's supposed to load values and not objects ... I don't need to store the objects but I would need to list it in a loop...
UPDATE 2 :
I managed to load some json object data into an array.
But i'm unable to extract it !
In debug mode I can see there is the data into the array.
But when I do :
foreach X,Y,Z from Array
log Array.CurValue
and str(Array.CurValue) doesn't help ...
Can you help, anyone ?