[SOLVED] JSON string not properly parsed

4ian fix it:


H̶i̶!

̶I̶ ̶w̶a̶n̶t̶ ̶t̶o̶ ̶s̶a̶v̶e̶ ̶a̶ ̶s̶t̶r̶u̶c̶t̶u̶r̶e̶ ̶t̶o̶ ̶a̶ ̶f̶i̶l̶e̶ ̶a̶n̶d̶ ̶r̶e̶t̶r̶i̶e̶v̶e̶ ̶i̶t̶.̶
I̶’̶m̶ ̶t̶r̶y̶i̶n̶g̶ ̶t̶o̶ ̶i̶m̶p̶l̶e̶m̶e̶n̶t̶ ̶t̶h̶i̶s̶:

M̶y̶ ̶i̶m̶p̶l̶e̶m̶e̶n̶t̶a̶t̶i̶o̶n̶ ̶c̶u̶r̶r̶e̶n̶t̶l̶y̶ ̶s̶t̶o̶r̶e̶s̶ ̶a̶ ̶J̶S̶O̶N̶ ̶f̶o̶r̶m̶a̶t̶e̶d̶ ̶s̶t̶r̶u̶c̶t̶u̶r̶e̶ ̶a̶s̶ ̶t̶e̶x̶t̶ ̶i̶n̶ ̶a̶ ̶X̶M̶L̶ ̶f̶i̶e̶l̶d̶.̶

̶T̶h̶e̶ ̶p̶r̶o̶b̶l̶e̶m̶ ̶o̶c̶c̶u̶r̶s̶ ̶w̶h̶e̶n̶ ̶I̶ ̶t̶r̶y̶ ̶t̶o̶ ̶p̶a̶r̶s̶e̶ ̶t̶h̶e̶ ̶J̶S̶O̶N̶ ̶s̶t̶r̶i̶n̶g̶ ̶i̶n̶t̶o̶ ̶a̶ ̶s̶t̶r̶u̶c̶t̶u̶r̶e̶ ̶a̶g̶a̶i̶n̶,̶ ̶i̶n̶ ̶G̶D̶,̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶"̶J̶S̶O̶N̶ ̶t̶o̶ ̶v̶a̶r̶i̶a̶b̶l̶e̶"̶ ̶a̶c̶t̶i̶o̶n.̶
I̶t̶ ̶s̶e̶e̶m̶s̶ ̶t̶o̶ ̶n̶o̶t̶ ̶b̶e̶ ̶p̶r̶o̶p̶e̶r̶l̶y̶ ̶p̶a̶r̶s̶i̶n̶g̶ ̶t̶h̶e̶ ̶d̶a̶t̶a̶ ̶I̶ ̶s̶t̶o̶r̶e̶d̶ ̶i̶n̶ ̶t̶h̶e̶ ̶f̶i̶l̶e̶.̶ ̶I̶n̶ ̶f̶a̶c̶t̶,̶ ̶i̶t̶ ̶s̶e̶e̶m̶s̶ ̶t̶o̶ ̶n̶o̶t̶ ̶b̶e̶ ̶d̶o̶i̶n̶g̶ ̶n̶o̶t̶h̶i̶n̶g̶.̶

  • I̶ ̶h̶a̶v̶e̶ ̶a̶l̶r̶e̶a̶d̶y̶ ̶t̶e̶s̶t̶ ̶t̶h̶e̶ ̶a̶c̶t̶u̶a̶l̶ ̶J̶S̶O̶N̶ ̶s̶t̶r̶i̶n̶g̶ ̶s̶t̶o̶r̶e̶d̶ ̶i̶n̶ ̶t̶h̶e̶ ̶f̶i̶l̶e̶ ̶w̶i̶t̶h̶ ̶a̶n̶ ̶o̶n̶l̶i̶n̶e̶ ̶J̶S̶O̶N̶ ̶p̶a̶r̶s̶e̶r̶ ̶a̶n̶d̶ ̶d̶e̶s̶p̶i̶t̶e̶ ̶a̶ ̶l̶o̶t̶ ̶o̶f̶ ̶s̶u̶p̶p̶o̶s̶e̶d̶ ̶e̶r̶r̶o̶r̶s̶ ̶t̶h̶e̶ ̶p̶a̶r̶s̶e̶r̶ ̶f̶o̶u̶n̶d̶,̶ ̶t̶h̶e̶ ̶d̶a̶t̶a̶ ̶s̶t̶r̶u̶c̶t̶u̶r̶e̶ ̶s̶e̶e̶m̶s̶ ̶t̶o̶ ̶b̶e̶ ̶r̶e̶a̶d̶a̶b̶l̶e̶:̶
  • I̶ ̶h̶a̶d̶ ̶c̶h̶e̶c̶k̶e̶d̶ ̶t̶h̶e̶ ̶p̶r̶o̶j̶e̶c̶t̶ ̶l̶o̶t̶s̶ ̶o̶f̶ ̶t̶i̶m̶e̶s̶ ̶f̶o̶r̶ ̶s̶o̶m̶e̶ ̶k̶i̶n̶d̶ ̶o̶f̶ ̶t̶y̶p̶e̶-̶m̶i̶s̶m̶a̶t̶c̶h̶.̶
  • T̶h̶e̶ ̶a̶c̶t̶i̶o̶n̶ ̶t̶h̶a̶t̶ ̶r̶e̶t̶r̶i̶e̶v̶e̶s̶ ̶t̶h̶e̶ ̶J̶S̶O̶N̶ ̶s̶t̶r̶i̶n̶g̶ ̶f̶r̶o̶m̶ ̶t̶h̶e̶ ̶X̶M̶L̶ ̶f̶i̶e̶l̶d̶ ̶i̶s̶ ̶w̶o̶r̶k̶i̶n̶g̶ ̶p̶e̶r̶f̶e̶c̶t̶l̶y̶ ̶a̶n̶d̶ ̶s̶t̶o̶r̶i̶n̶g̶ ̶t̶h̶e̶ ̶s̶t̶r̶i̶n̶g̶ ̶a̶s̶ ̶t̶e̶x̶t̶ ̶i̶n̶ ̶a̶ ̶v̶a̶r̶i̶a̶b̶l̶e̶.̶

T̶h̶e̶ ̶p̶r̶o̶b̶l̶e̶m̶ ̶s̶e̶e̶m̶s̶ ̶t̶o̶ ̶b̶e̶ ̶i̶n̶ ̶t̶h̶e̶ ̶p̶a̶r̶s̶e̶r̶;̶ ̶t̶h̶e̶r̶e̶ ̶i̶s̶ ̶w̶h̶e̶r̶e̶ ̶e̶v̶e̶r̶y̶t̶h̶i̶n̶g̶ ̶g̶o̶e̶s̶ ̶w̶r̶o̶n̶g̶.̶ ̶

̶A̶t̶ ̶t̶h̶i̶s̶ ̶p̶o̶i̶n̶t̶,̶ ̶I̶ ̶d̶o̶n̶’̶t̶ ̶k̶n̶o̶w̶ ̶w̶h̶a̶t̶ ̶m̶o̶r̶e̶ ̶c̶a̶n̶ ̶I̶ ̶d̶o̶ ̶b̶u̶t̶ ̶I̶ ̶p̶r̶e̶f̶e̶r̶ ̶t̶o̶ ̶f̶i̶n̶d̶ ̶o̶u̶t̶ ̶i̶f̶ ̶I̶’̶m̶ ̶d̶o̶i̶n̶g̶ ̶s̶o̶m̶e̶t̶h̶i̶n̶g̶ ̶w̶r̶o̶n̶g̶ ̶
b̶e̶f̶o̶r̶e̶ ̶g̶o̶i̶n̶g̶ ̶t̶o̶ ̶t̶h̶e̶ ̶"̶r̶e̶p̶o̶r̶t̶ ̶a̶ ̶b̶u̶g̶"̶ ̶f̶o̶r̶u̶m̶ ̶.̶.̶.̶ ̶s̶o̶,̶ ̶I̶’̶l̶l̶ ̶r̶e̶a̶l̶l̶y̶ ̶a̶p̶p̶r̶e̶c̶i̶a̶t̶e̶ ̶a̶n̶y̶ ̶h̶e̶l̶p̶.̶

̶P̶l̶e̶a̶s̶e̶ ̶t̶a̶k̶e̶ ̶a̶ ̶l̶o̶o̶k̶ ̶a̶t̶ ̶t̶h̶e̶ ̶"̶s̶a̶v̶e̶_̶s̶t̶r̶u̶c̶t̶u̶r̶e̶_̶t̶o̶_̶f̶i̶l̶e̶"̶ ̶a̶n̶d̶ ̶"̶l̶o̶a̶d̶_̶s̶t̶r̶u̶c̶t̶u̶r̶e̶_̶f̶r̶o̶m̶_̶f̶i̶l̶e̶"̶ ̶f̶u̶n̶c̶t̶i̶o̶n̶s̶ ̶i̶n̶ ̶m̶y̶ ̶p̶r̶o̶j̶e̶c̶t̶:̶

dynamic_structure_to_file_2.gdg (40.4 KB)

T̶h̶a̶n̶k̶s̶ ̶i̶n̶ ̶a̶d̶v̶a̶n̶c̶e̶!̶

Really weird.
By the way, when I compile your project in an exe and launch it, it crashes. Do you have the same problem ?

Well, yes, it crashes.

I had check the entire project searching for a type-mismatch caused by me (maybe trying to set a value in a text field, I don’t know, something like that), but it doesn’t seems to be the case.

Yes, don’t know exactly what causes the crash and can’t reproduce it outside this project (I’ve created an issue on Github : https://github.com/4ian/GD/issues/89)

Ok, solved it, the Text object extension wasn’t activated (don’t know why though). Just add it and it will work (it doesn’t cause a crash when previewing because all extension are loaded in memory but it’s not the case when the game is built as only the activated extensions are copied).

Yes, thanks about that, I fixed when I see your comment in GitHub.
I don’t know neither why that extension was deactivated (I can’t remember to do such thing).
Anyways…

In the other hand, the JSON parser is NOT working yet, at least for me.

The problem seems to be related to the double pair of quotes ( {“5”: "“3"”} ) :neutral_face:

Yes, but that string is the result of the ToJSON() function built in GD. I just stored in a XML field as it is :frowning:

Ok, strange behavior from the XML parser. :confused:

Looks like the JSON writer integrated to GD is failing when double quotes are used in a string.

I understand, but those double quotes are produced by the ToJSON() expression integrated in GD.
So I don’t have idea how to solve it (unless I implement a custom function event to fix the JSON string) :neutral_face:

It was a bug in the “Variable to JSON” writer of GD. Fixed (github.com/4ian/GD/commit/d4cfc … b176ab20a3) and added automatics tests for it.

I’ll try to release a new version soon! Thanks for reporting the bug :slight_smile:

Thanks!