Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] JSON help. Array of array of numbers

Author
Message
Scotty1973
AGK Backer
13
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 22nd Sep 2018 21:09
Hi

I have a JSON file i'm trying to read in. I was jumbling through it when I got completely stuck.
In the file below it's the layers bit that i'm stuck on, in it is the tiles part and all I seem to do is read the the first element of the tiles array.



The code im using is



Im just not sure how to move onto the next array element or if the JSON file is not standard.

Many thanks

Scotty

The author of this post has marked a post as an answer.

Go to answer

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Sep 2018 15:11
A link to the json library you're using would help as I have no clue what commands are used for reading json files.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 24th Sep 2018 15:22 Edited at: 24th Sep 2018 15:22
Its almost certainly Madbit's library that he is using by the looks of those commands:
https://forum.thegamecreators.com/thread/218297
Scotty1973
AGK Backer
13
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 24th Sep 2018 15:49
Quote: "A link to the json library you're using would help as I have no clue what commands are used for reading json files."


Yes sorry Phaelax it would be a good idea

Quote: "Its almost certainly Madbit's library that he is using by the looks of those commands:"


As Bengismo says it is Madbit's library.

Scotty
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 24th Sep 2018 17:29
This post has been marked by the post author as the answer.
First of all, thank you for using my library.

I changed your code a little, I think it could work that way. I didn't test it.
Otherwise I have seen only a small mistake. You tried with jsonGetObjectValueById to read a value from an array that only reads values from an object.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Scotty1973
AGK Backer
13
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 25th Sep 2018 00:04
Hi MadBit

Your JSON library is a great addition to AGK.
I have tested your code, which is of great help for me. You state the following.

Quote: "for y =0 to (rowCount-1) // -1 because agk counts up to and including 'rowCount'. That would be one too many. "

Quote: "for x = 0 to (columnCount-1)"


I have found that is you use the -1 it misses the last item in the array so I took that out.

Also i've added jsonGetValueAsInteger(docId,t,10) to get the value out of the array.

I really appreciate you help and great library.

Many thanks

Scotty
MadBit
VIP Member
Gold Codemaster
15
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Sep 2018 07:55
Ohh, that's my fault. I switch so often between C++ -> AgkBasic -> C# that I confuse some things.
Sorry.
But glad I could help.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)

Login to post a reply

Server time is: 2024-11-23 04:55:43
Your offset time is: 2024-11-23 04:55:43