Crate an array associative from a php return array

Crate an array associative for each values of an array that return from sql Query like this:

[{“firstname”:“daniele”,“lastname”:“daveri”,“username”:“dany”,“gender”:“male”},{“firstname”:“admin”,“lastname”:“admin”,“username”:“admin”,“gender”:“male”},{“firstname”:“prova3”,“lastname”:“prova3”,“username”:“prova3”,“gender”:“male”},{“firstname”:“pp”,“lastname”:“pp”,“username”:“pp”,“gender”:“male”}]

Thanks !

This is outside of the scope of Unity as you’ll need a JSON deserializing library which im not sure if it would run in the Mono 2.0 subset for Unity… depends also on what you are targeting, iOS, android, PC, etc.

You can however try and manipulate the string itself manually. first, remove the 's from the string, then (in PHP terms) explode the string on },{ (to avoid picking up all the ,s) using:

String array_info = jsonstr.Split(new String {“},{”}, StringSplitOptions.None);

then strip out the remaining { or } and then Split again on the comma ,

then further split on the : and strip out the "s and iterate through your new arrays and form your new main array to handle it.

While this approach isn’t ideal, it avoids having to use JSON libraries since c# does not have a built in approach for this, and i’m not sure what would be supported on your target platform for Mono 2.0 subset