How to set -D haxeJSON


#1

Hi,

I would like to know how could I set -D haxeJSON to have the native JSON implementation on Android.

Tried to set but it looks like that this dont work.

I am struggling with sorting problems with JSON Data.

Best Christian


#2

I’m guessing this is a follow-up for this thread? :wink:

Haxe’s JSON implementation should already used on Android (cpp), so haxeJSON wouldn’t make any difference here. As the docs state:

The haxe.Json API automatically uses native implementation on targets where it is available, i.e. JavaScript, Flash and PHP and provides its own implementation for other targets.

-D haxeJSON becomes -DhaxeJSON with Lime when compiling through the command line, or <haxedef name="haxeJSON" /> in project.xml.


#3

Yes it is a follow-up. So there is no chance to have a sorted order of objects using JSON?

like this one?

1 : {
prestige : 0,
lottery : 1
},
2 : {
prestige : 300,
lottery : 1
},
3 : {
prestige : 600,
lottery : 1
}

on android these objects wont have any order


#4

What is it you’re doing exactly? Reading JSON? Writing JSON? There’s several JSON libaries for Haxe that might help.

Couldn’t you use an array instead? No issues with order there.


#5

We highly use JSON files as configuration for our game. Means I load a json file then reading them via haxe.JSON.parse. In most of my cases the order is relevant. I know that I could use an Array instead but this will result in a huge refactoring, as our codebase is ported from AS3.

Do you have an example lib for Haxe JSON?


#6

As I mentioned, there’s quite a few:

I didn’t check if any of them guarantee a stable field sort order.