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.

AppGameKit Classic Chat / JSON Reader / Writer / Modifier API [Tier 1]

Author
Message
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 18th Nov 2016 11:53 Edited at: 16th Aug 2017 04:13
Hi folks,

I have written a JSON load / save / create and modify API for AppGameKit (Tier1).
I hope you can start something with it. You get the code from the codebase.
I wanted to share this API for free via the TGC-Store. But I did not agree with a few terms on registering. So I share
it on this way.

Here to survey the function list.

How to use this API?

Create and Save a new JSON_File



Load and use a JSON-File



Modify and save JSON-File



I'm sure the interested user has a few questions. I try to answer them as well as possible.

Have fun with it.

Please download new file below or see codebase.
EDIT: [2017-08-16]
Changes
Bug Fix. Incorrect shortening of the floating point numbers. (thanks George++)

EDIT: [2017-02-24]
Changes
Bug Fix. Error message appears if the document have no whitespace behind the last brace.( thanks Wilf!!! )
Bug Fix. Error message by using an invalid document id in function jsonLoad. If the id out of bounds, then a new id is generated and returned.


EDIT: [2017-02-23]
Changes
Add. 'jsonCreateFromString'. With this new function, you can create a new document from a string. ( Proposed by Phaelax, thanks )
Change (internal). The file is no longer directly 'parsed'. Now the file is loaded in a memblock and parsed from this.
Bug Fix. jsonLoad works as described in the last release.


EDIT: [2017-01-05]
Changes
Change. The JSON-Document must now be an integer and no longer from the TYPE jsonDocument. ( thanks BatVink )
Fix. jsonSetArrayValue works now correctly.
Fix. If you create a new document on an existing document, the old one will be deleted
Change. jsonLoad will now automatically create a new document. You do not need to call jsonCreateDocument before.


EDIT: [2016-12-11]
Changes:
Float Values: Truncate trailing zeros. (beautify the output )
API now #option_explicit compatible (mentioned by MikeHeart)

MadBit!
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine

Attachments

Login to view attachments
Wilf
Valued Member
16
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 18th Nov 2016 12:27
This looks fantastic, well done and thank you Madbit!
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Nov 2016 13:38
Very nice! Thanks for sharing
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
baxslash
Valued Member
Bronze Codemaster
15
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Nov 2016 14:46
Very handy! I may well use this for one or two projects I am working on

Thanks!
Using AppGameKit V2 Tier 1
Ortu
DBPro Master
14
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 18th Nov 2016 15:02
Nice man, I'm a big fan of json.


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
CJB
Valued Member
18
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 18th Nov 2016 16:47
Great stuff! This opens up quite a few more real-world uses for AGK. Good work
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Mobiius
Valued Member
19
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th Nov 2016 16:49
Handy for the google reverse geotagging api, which returns data in json format.
CJB
Valued Member
18
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 18th Nov 2016 17:01
Exactly. API interaction is where this code is going to be incredibly useful. I can think of tons of API's that transact in JSON. e-mail services (mailgun), virtual currency exchanges, blogging services, weather services... the list is endless.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Jack
17
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 19th Nov 2016 23:38
Thank you Madbit!

A great API!

I have some work to do right now and can't do experiments with your awesome API, but I will use this as a replacement for
the old xml parser
Acutally the json file can open some new dimensions for us. Combined with the Tier1 expression evaluator
we could share assets including their initialization, like already applied shaders / images/ animations and even more...

AGK2 T1 scripting language, when?
And thank you for sharing it in the codebase

[/url]
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 20th Nov 2016 00:47
Thank you all for your nice words. I'm glad that the Api is so positively received by you.
I would like to show you a small example. It loads a JSON file and saves it to a different format. There you can see how to navigate through a complete JSON file.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
CodeTrasher
10
Years of Service
User Offline
Joined: 18th Jul 2012
Location: Tampere, Finland
Posted: 20th Nov 2016 06:07
Fantastic, thank you! I ws going to start working on similar project but it seems that I don't need to. Great job!
Mah machine: Intel Xeon E3-1231v3 4x3.40GHz | CM Hyper 212 Evo | ASRock H97 Pro4 | 240GB SanDisk SSD | Sapphire Radeon R9 270X Dual-X 2048MB | Seagate HDD 1000GB |
8GB Crucial Ballistix Sport DDR3-1600
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Dec 2016 15:33
I now have a use for this

I have a spreadsheet system with lots of data to present.
I will export from Excel as JSON and use a templating system to find the data n the JSON file to present.
In theory I can present lists of data in a generic way by getting the data by JSON path. I don't have to pre-build arrays with a set format.

I'll let you know how I get on.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Dec 2016 21:38
OK..I spent this evening creating a script to write out my data from Excel into JSON format. It's all validated OK

I have loaded it into AGK:



But now...how do I get a string value out of the JSON data?
My next question will be how to get values out of arrays.

For example, how do I get winningFundAdjust (string)?
And how will I get the colour values for the nth colour.





- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
MikeHart
AGK Developer
19
Years of Service
User Offline
Joined: 9th Jun 2003
Location: Germany
Posted: 10th Dec 2016 10:47
While I appreciate the effort and sharing, when you use #option_explicit which I recomment to everyone, your code needs heavy changes.
-----------------------------------------------------------
Using AGK2 Tier 1
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 10th Dec 2016 15:03 Edited at: 10th Dec 2016 15:04
BatVink wrote: "I now have a use for this
"

I am pleased about everyone who uses the lib.

BatVink wrote: "But now...how do I get a string value out of the JSON data?
My next question will be how to get values out of arrays.

For example, how do I get winningFundAdjust (string)?
And how will I get the colour values for the nth colour.
"

That is not so hard. I hope.

To get an object from the json file, use 'jsonGetObject'
Paremeter doc must always be specified (for each function).
Parameter path is the path to the object. If you want to have the 'root' object, you pass an empty string. If you want to have a nested object, you separate the path with the tilde. E.g. "Object1~object1_1~object1_1_1". Note it is casesensitiv.

The same is true for arrays. To get an array, you use 'jsonGetArray'
Specify the parameter doc as always.
Parameter path is the path to the object of the array.
Parameter key is the key-by of array itself.

To get a value from an array, use 'GetArrayEntry'
Parameter doc you already know ...
Parameter aryID. The id you got back from 'jsonGetArray'.
Parameter index. The index entry you want to have from the array.

To convert a entry into a usable value you use 'jsonGetValueAs???'
(??? = Integer or String or Float or Boolean or Null)
Int = jsonGetValueAsInteger (doc, entryID)

For your example, it would be something like this.


MikeHart wrote: "While I appreciate the effort and sharing, when you use #option_explicit which I recomment to everyone, your code needs heavy changes. "

Ok, this is an argument. I'll see what I can do.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 10th Dec 2016 15:18
What does jSON stands for?
Can I use it for saving map files generated from my map tile editor?
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 10th Dec 2016 15:34
Json stands for JavaScript Object Notation
And yes you can use it for your mapfiles.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 10th Dec 2016 16:32
Thank you, I'll try to include your library into my project.
MikeHart
AGK Developer
19
Years of Service
User Offline
Joined: 9th Jun 2003
Location: Germany
Posted: 10th Dec 2016 20:46 Edited at: 11th Dec 2016 09:32
MadBit wrote: "Ok, this is an argument. I'll see what I can do."


You need to. For an example, you have an elseif without a condition. AGK2 considers this a bug but without #option explizit it doesn't report it, i think. Could also be the bad formating in the codebase that * this error up.
-----------------------------------------------------------
Using AGK2 Tier 1
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Dec 2016 07:17
I have now uploaded a new version. See first post for changes and download. Since I can not upload files in the codebase. Can you do this in the first post. I have the code in the codebase also updated.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Dec 2016 09:31 Edited at: 11th Dec 2016 09:32
Madbit, that is a good example of using the functions, thank you. Once you see it explained, it makes perfect sense.


Quote: "Could also be the bad formating in the codebase that *** this error up."


I had to edit the code after copy/pasting. It added extra characters and removed a few line breaks. The download option doesn't work, it thinks you are always logged out.
So it is good that you have attached the file, thanks

(Mike, I have to ask as a moderator that you don't swear in your posts )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Dec 2016 10:52
Reporting back:

I have downloaded the latest code, and tested have successfully read my data

In case it inspires anyone else, here is my plan to write a generic list presentation screen (e.g high score board, list of racers etc...)

1. Get your data in a JSON array format.
2. Have another JSON file that describes the list you want to present:
* Header info (list area, back image, number of cols etc)
* JSON path to list
* List of JSON entries to display in each row
* array of column formats (width, back image, font size, colour etc).

From this, you should be able to display any list as drop-in module to your project.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
janbo
Tower Defence Competition 2nd Place
13
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 11th Dec 2016 17:35 Edited at: 12th Dec 2016 00:03
Hello,

May I ask here for a little example and help with my problem ?
I don't understand what each function does and what I need in correlation with some of the functions as json parsing an such a thing is kind of new for me..
I do understand the examples in that small manner

So I Have this json string retrieved from a weather API:


I already have a working app where I kind of hard coded each parameter I need to extract.
Now how would I extract the" temperature" and/or "humidity" from each "main" section ?
I can extract the "name" from the "city" but not the "list" or something else below "city"

You must not make an example for me but I would greatly appreciate it

Using AGKv2 Tier1
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 11th Dec 2016 20:49 Edited at: 11th Dec 2016 21:15
I looked at your weather json file. The 'main' section is a nested object in another object, which is nested in the list-array, which in turn is nested in the root object.

here's an example to access for 'humidity' value:



If you do not know what value type is your value. Then you can get it out with jsonGetValueType (doc, valie_id). The types are defined as constants at the beginning of the json.agc file.

I hope this help.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Dec 2016 23:19
I needed to make the code easier to use with other modules in my code. To do this, I have changed the jsonDocument in jsonCreateDocument() to an integer (reference to an array element held inside the json module). _jsonDocuments[] holds the data.
You only need to change 2 lines and the rest of the code works. But it makes the module really easy to use with other code No need to pass a jsonDocument by reference into other functions.

Where you start the code with:

doc As jsonDocument
jsonCreateDocument(doc)

Change it to:

doc as integer
doc = jsonCreateDocument(-1)


You can call this as many times as you need, it will return a new integer each time, and the json module will create a new jsonDocument.

Here is my revised version of your code:



I cannot test everything, but I think it is stable.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 12th Dec 2016 07:20 Edited at: 12th Dec 2016 07:22
BatVink wrote: "I needed to make the code easier to use with other modules in my code. To do this, I have changed the jsonDocument in jsonCreateDocument() to an integer (reference to an array element held inside the json module). _jsonDocuments[] holds the data."

If this work better for you, that is ok.

BatVink wrote: "No need to pass a jsonDocument by reference into other functions."

But I do not see a big advantage at the moment. Whether I pass an integer or the document as a reference.
I'm not really convinced of the change yet. But maybe you can still convince me.

If you no longer need the document then you must also delete it yourself, in order to avoid a memory leak.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Dec 2016 08:30 Edited at: 12th Dec 2016 08:45
Quote: "I'm not really convinced of the change yet. But maybe you can still convince me. "




Here is my scenario, but there are others...

I have a module of functions for displaying lists of data. Currently it works with an ini file format. The ini file is already in a module similar to yours for JSON, with a lot of supporting functions.
So at the moment I have...

* Ini File module
* Display module


When I want to display a list from the ini file, I pass in an ini file ID (integer) .
Now I want to use the same display module with your JSON module. And maybe I want to extend it to XML in the future...

* Ini File module
* JSON module
* XML module
* Display module


with integer references, the code to use these modules is really flexible, and the coder doesn't need to think about which type to use for which option...

doc = JSONcreatedocument()
or
doc = loadINIfile()
or
doc = importXML()

in the display module configuration...

setDisplayFileFormat(doc, cJSON)
or
setDisplayFileFormat(doc, cXML)
or
setDisplayFileFormat(doc, cINI)


Now I have the same function calls for any format...

listData(doc)

in the module when you call a function...



This is the same code without integer references, but more complicated for the coder...

doc as JSONdocument
or
doc as iniFile
or
doc as XMLfile

then 3 functions for every method...

displayListJSON(doc)
displayListXML(doc)
displayListINI(doc)


and if I have different files (one ini file and one 2 JSON files for example) then I need different variables to store each one, instead on one array list of integer references...

global JSONdoc[2] as JSONdocument
global INIdoc as INIfile

instead of..
global doc[2] as integer


But really the most important thing is that the JSON module is completely self-contained. You can give it to anybody and they don't need to know anything about the internal structure and data types. All they need to know is that they need an integer to store the reference, and how to get/set, load and save data.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 12th Dec 2016 10:22 Edited at: 12th Dec 2016 10:30
Yes, in this scenario it can be an advantage. But this problem could also be solved without changing the entire API. (I know Search and replace are your best friend, in this case. )
Ok, but with some more programming work.

your global json-array
Global in_app_json_doc_array As jsonDocument[]

load json in array. can also be in a extra function
in_app_json_doc_array.insert(jsonLoad(doc, "myfile.json"))
myfile_id = in_app_json_doc_array.length


Or something more elegant, if you have no influence on the APIs. With its own structure.


There's more than one way to skin a cat. (Is this the right saying? In German I would have said 'many ways lead to rom.')

But that is why we are all programmers, to form the environment to our liking.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
janbo
Tower Defence Competition 2nd Place
13
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 12th Dec 2016 13:35 Edited at: 12th Dec 2016 14:51
Hey, thank you very much MadBit

Is it right that currently there is no way to create a doc reference from a string directly
If I had no access to the code I must save my string, I got from the API, to a json file and then load it again with JsonLoad(doc,File) right ?

[Edit]
I get a bit familiar with you functions
But now I stuck on the "description" in the "weather" array ...extract an entry from an array inside another array ?
[/Edit]

Using AGKv2 Tier1
BatVink
Moderator
19
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Dec 2016 18:42
Quote: "There's more than one way to skin a cat"


Yes, that is the phrase
And it is true. All programmers have their own way to do things. Because I changed it, I contributed it back to the community, in case anyone else has this preference.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 13th Dec 2016 08:06
janbo wrote: "But now I stuck on the "description" in the "weather" array ...extract an entry from an array inside another array ?
"

Hmmm, 'weather' is an array, but the contents are objects. In this case only one.
(For the explanation: '{} encloses an object and' [] 'encloses an array)

To get access, you only have to get the 'Weather' array instead of the 'Main' object. And then get the first object from this array. Now you can access all values in this object.

If you still need a code example, then tell me.

@BatVink
I thought about it. And will take these changes, to the next release. However, only to meet the AGK-ID system.
Thanks for the inspiration.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
janbo
Tower Defence Competition 2nd Place
13
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 13th Dec 2016 21:28
I thought I need jsongetarray
But I got it now thanks

Using AGKv2 Tier1
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 2nd Jan 2017 18:24
I think the following code has a bug

It should be


Could someone confirm?
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 3rd Jan 2017 18:20
Sorry no.
This function is to return a JSONValue from which you can get a real value (integer, float, boolean or null).
So the returned JSONValue must not be an object or array.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 3rd Jan 2017 19:52
Hi MadBit and thank you for your response.
The following code (it's a composition of the examples you gave in your first post):


will work only with the modification I posted above
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 3rd Jan 2017 20:39
Yes you are right. The error is not in the function, but in the example.
Sorry, my mistake. and thank you.

Change line 49 so ...

Or even so ...



Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 3rd Jan 2017 21:09
Thanks a lot. This will help me to proceed with my project.
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 4th Jan 2017 20:42
I have the following data file, which has been created by the json routines

Could you please give me an example of how to retrieve the value of the "name" property (map.pte) and the values of the second object of the "tiles" array ("id": 14...)
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 4th Jan 2017 23:32 Edited at: 4th Jan 2017 23:34
I hope this help.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 4th Jan 2017 23:59 Edited at: 5th Jan 2017 00:00
I ran the code in debug mode and the mapName equals to an empty string because the mapNameId equals to -1 (I didn't check the rest of the code)
I have attached the data file in any case

Attachments

Login to view attachments
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 5th Jan 2017 00:29
I've tried it. It works for me. I have it also checked over the debugger.
I guess agk does not find the json file. Please check it via GetFileExists if AppGameKit finds the file.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 5th Jan 2017 06:39
I really appreciate spending your time on this issue.
It seems through the debugger, that the file is opened.
Is it possible to send by e-mail the library?
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 5th Jan 2017 09:51
Here is a whole project that works for me. It contain the actual version of the lib. I have also updated the first post with the new API to download.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine

Attachments

Login to view attachments
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 5th Jan 2017 10:53
Once again thank you.
The project you sent is working.
Now I have to change my main project because I was using a previous version of the json lib. For example the parameter for the jsonCreateDocument needs an integer and not a jsonDocument type
When I'll return to my home I will make the necessary changes.
Given the chance, I have to say that you have done a very good job with this library, and in my opinion, needs to become somehow "official"
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 5th Jan 2017 21:30 Edited at: 5th Jan 2017 21:31
I ran the test project for first time in order to create the data file
Then I commented the creation commands and modified the data file as follows: I changed the "id_ts" from 0 to 1 on the second line (id=14)
The lib does not read the "id_ts" 1 but still reads 0
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 5th Jan 2017 22:07
I did the above test because I cannot to read the cell size values (12, 18) of the following file


using the following commands:
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 6th Jan 2017 01:06 Edited at: 6th Jan 2017 01:08
Hmm OK,
I have made it the same way as you. The program-generated file is written in the default-directory 'C:\Users\$(USER)\AppData\Local\AGKApps\George-Test\media\georg.json'. This file I have changed by hand as you.
I showed the same problem that only the old 'cellsize' values ​​read (128, 128). I then renamed the file to georg2.json.
Then I had the problem that the file is not found. Then I moved (not copy) the file 'georg2.json' into the media folder of the project.
Now the correct values ​​were read out.
After moving back (also no copy), he found the file surprisingly and also correctly read out.
After searching the hard drive, I discovered a second directory that is created by agk under windows. 'C:\Users\$(USER)\AppData\Local\AGKApps\Windows\George-Test\media'. There I found 'georg.json and' georg2.json '.

I dont know if this a bug of agk or not.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
damothegreat
User Banned
Posted: 6th Jan 2017 01:13
Nothing is a bug unless things were should be programmatically for this feature

- no one can beat all eventualities

- is it a design feature

- is a new feature that could be introduced in later releases

Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Works with a Lenovo IdeaPad 700, 1TB SSD (Data), 128GB HD (System), 12GB Ram, GeForce Nvdia 950M, Windows 10, 2.3Ghz (Turbo to 3.2ghz when required)
george++
AGK Tool Maker
15
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 6th Jan 2017 10:24 Edited at: 6th Jan 2017 10:27
@MadBit: Your lib works fine. I found the explanation:

The folder:
'C:\Users\$(USER)\AppData\Local\AGKApps\Windows\George-Test\media'

is used by the AppGameKit when the application runs under debug mode and the folder:
'C:\Users\$(USER)\AppData\Local\AGKApps\George-Test\media\'

is used when the application runs without debugging mode
It is not an AppGameKit bug but I think this behavior should be clearly given in the AppGameKit manuals.
MadBit
VIP Member
Gold Codemaster
13
Years of Service
Recently Online
Joined: 25th Jun 2009
Location: Germany
Posted: 6th Jan 2017 11:40
@george++: thanks for this hint.


Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine

Login to post a reply

Server time is: 2022-09-30 10:43:02
Your offset time is: 2022-09-30 10:43:02