Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Found this old entry: https://www.ambiera.com/forum.php?t=4929 that hint that encoding and decoding json might be possible. (maybe only in the webgl target) But both mentioned urls are not working anymore. Is JSON possible and if so how? var myObj = { "name":"John", "age":31, "city":"New York" }; is not the way to go, as JSON is not defined. |
||||
|
Yes, you would have to include a Json parser library, then it would work. You could also use eval() to parse the json, this would work. It is vulnerable to attacks, but if you are using it in a game only - for example for reading config files - this should be ok. |
||||
|
eval works like a charm :-) though a parser via an include sounds better, but no clue how to do that with coppercube as i dont know where to put it and how to refer to it. |
||||
|
figured it out on the scene node on the behaviour i added the Before first drawing do something on action i added multiple execute javascript actions in the first execute javascript i added: https://bestiejs.github.io/json3... so now i can do as usual in the next execute javascript and maybe everywhere from coppercube: var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}'); |
|