Using LitJson in unity 3D

2 questions.

1) Is it possible to use the LitJson library, as when writing scripts in Javascript? This is a really general question about the possibility of using a C # source in a javascript source.

2) I am new to C # dev. I can't seem to get Litson to work. The following code generates this error: An object reference is required to access non-static memberLitJson.JsonReader.Read () ''

using UnityEngine;
using System.Collections;

public class Loadr : MonoBehaviour {
string url= "http://developer.echonest.com/api/v4/artist/images?api_key=N6E4NIOVYMTHNDM8J&id=ARH6W4X1187B99274F&format=json&results=1&start=0&license=unknown";
void  Start (){
    WWW www = new WWW(url);
    print(www.text);
    Object a = LitJson.JsonReader.Read(www.text);
    print(a.response.status);

    }

}

any thoughts?

+5
source share
4 answers

Json- Unity3D. , , /, iOS, WebPlayer Editor, JsonFX JsonSerializer 1.4.

, , , JsonReader, .

- :

var reader = new LitJson.JsonReader();
Object a = reader.Read(www.text);

Edit:

, . UnityScript, #. , using, import. #, , UnityScript (var blah : Type = YadaYada();)

+5

Hm. Jayrock? , , , , .

0

LitJSON for Unity3D:


LitJson , JSON-Lib, Unity3D Types, Enums .

GitHub: Tiny-JSON

:

// encode
Animal a = new Animal(4);
string json = Json.Encode(a);

// decode
IList<Animal> a = Json.Decode<IList<Animal>>("[{\"legs\":4}, {\"legs\":2}]");
0

  • js- # script, js- int Plugins .

  • Object a = LitJson.JsonReader.Read(www.text);
    , JosnReader , JsonRead, Read ( ) mehotd

0

All Articles