Parse JSON with LitJSON

I would like to parse a JSON using LitJSON. My JSON looks like :

{
    "title_roof": "TILESen",
    "detailsRed": "Classic red",
    "detailsRedShaded": "Shaded red",
    "detailsGreen": "Forest green",
    "detailsGreenShaded": "Shaded green",
    "detailsTerracota": "Terracotta",
    "detailsBrownShaded": "Shaded brown",
    "detailsBlack": "Black ",
    "title_wall": "WALLS",
    "wall1": {
        "name": "wall_name",
        "normal_texture": "normal.png",
        "hover_texture": "hover.png",
        "wall_texture": "texture.png"
    },
    "wall2": {
        "name": "wall_name_2",
        "normal_texture": "normal2.png",
        "hover_texture": "hover2.png",
        "wall_texture": "texture2.png"
    },
    "tile1": {
        "name": "tile_name",
        "normal_texture": "normal.png",
        "hover_texture": "hover.png",
        "details_texture": "details.png",
        "roof_texture": "roof.png",
        "ridge_color": "001144"
    }
}

I tried using this idea but i am geeting error like:

Expression denotes a `type’, where a “variable”, “value” or “method group” was expected

when i use :

using UnityEngine;
using System.Collections;
using LitJson;
public class Loadr : MonoBehaviour {
string url= "http://domain/site/get_texts.php"; //this is where i get my json
	
void  Start (){
    WWW www = new WWW(url);
    print(www.text);
    var a = new LitJson.JsonReader(www.text);
    print(a.ToString());
    }
}

How can i parse the json to access all the walls or all the tiles (in reality there will be more than then one) and access “name” property for e.g. ??

This line:

Object a = LitJson.JsonReader(www.text);

That’s a constructor call, yes? If so, you’ll need to use the new keyword:

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

Also, you might want to store the reference as something other than an Object. You may get a compiler error if the system thinks you meant UnityEngine.Object as opposed to System.Object.

Try the newly improved JSONParse:

http://wiki.unity3d.com/index.php?title=Head_First_into_Unity_with_UnityScript

To parse the data you’d write:

var data : json = json.fromString( your_JSON );

to grab stuff out of it you use:

data._get( key ) (and it chains, so you can data._get(“wall1”)._get(“_name”).string_value;

Everything is nested json objects (see the code for further documentation).

I’ve been able to add a certain amount of syntax sugar for generating new json, but it’s harder to make it work the other way.