I have a var in JSON Format, which is : var text= “{name: ‘Luiz’}”.I want to convert it into a javascript object. How can I do?
You can’t convert it into a javascript object, since there’s technically no javascript in Unity.
There is unityscript, which is based on javascript (and often mislabeled js, even by unity themselves)… but since it actually compiles to CIL, and is interpreted by the Mono-runtime. There is no javascript entities like its dynamic object.
Instead you have .Net objects. And .Net objects don’t inherently support dynamic objects (where you can just add fields/properties to an arbitrary object willy nilly). Instead you must create a class/struct with the shape of the json, and then deserialize it with the JsonUtility.
Another option (though not directly supported by JsonUtility) is to deserialize it into a Dictionary where the properties are the ‘key’ of the dictionary, and the value is the value of the dictionary. But you don’t get property notation to access it, but rather access it through the [key] notation. But since JsonUtillity doesn’t actually do this, you’ll have to parse it yourself… or use one of the various 3rd party json parsers to do it… like Json.Net.