How do I get array items

Get help using Construct 2

Post » Tue May 26, 2015 12:04 pm

Hi there,

I'm using a array to retrieve high score numbers and names from a server.

The string i retrieve is as this:
Code: Select all
{
"c2array":true,
"size":[10,2,1],
"data":[
["Jeroen",5000000],
["Harm",4587],
["Steven",1000],
["Pascal",999],
["Michael",998],
["Pim",722],
["Winnie",633],
["Elleke",598],
["Jeroen",579],
["Albert",527]
]
}


But when i use Array.at(0,0) or Array.at(1,0) i just get the first letter of each name.
ImageImage

What's happening???
B
3
Posts: 2
Reputation: 179

Post » Tue May 26, 2015 12:19 pm

try this string
Code: Select all
{"c2array":true,"size":[10,2,1],"data":[[["Jeroen"],[5000000]],[["Harm"],[4587]],[["Steven"],[1000]],[["Pascal"],[999]],[["Michael"],[998]],[["Pim"],[722]],[["Winnie"],[633]],[["Elleke"],[598]],[["Jeroen"],[579]],[["Albert"],[527]]]}
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Tue May 26, 2015 12:26 pm

Thanks
That worked
B
3
Posts: 2
Reputation: 179

Post » Tue May 26, 2015 8:29 pm

You have to include all three dimensions when working with C2-array JSON strings. You were missing the last dimension in your original string. It was included in @korbaach 's string.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests