[SOLVED]JSON parsing nightmare!

Can anyone help with this please … I need to pass a JSON string (I assume it needs to be a string) into a script and then work via typical JSON methods.

var jsonString : String = "json = { 'objectName' : 'jointA' , 'center' : '5.0 5.0 5.0' , 'diameter' : '5.0' }";

function Start (jsonString)
{
	var json;
	
	eval(jsonString); 
	
	var center = json["center"];
	
	Debug.Log(center);
}

But, I get the following error message on the eval statement:

Typical JSON methods do not apply to Unity “JavaScript” (which is entirely different from web-based JavaScript). You’ll need to look up a .NET solution for JSON.

I guess my problem really has to do with getting the JSON “code” into the script in the first place – not so much how to work with it once its there … For example, the following works …

function Start ()
{
	var json = { "objectName" : "jointA" , "center" : "5.0 5.0 5.0" , "diameter" : "5.0" };
	
	var center = json["center"];
	
	Debug.Log(center);
}

The argument assigned to “json” has to be passed into the script and this is where I am getting into trouble. Does it have to do with embedded strings or something???

Thanks for the help!!

This seems to work …

var jsonString = "{ \"objectName\" : \"jointA\" , \"center\" : \"3.0 4.0 5.0\" , \"diameter\" : \"22.0\" }";

function Start ()
{
	var jsonHash : Boo.Lang.Hash = eval(jsonString);
	
	for (key in jsonHash.Keys) 
	{
		Debug.Log ("key:"+key+", value: "+ jsonHash[key]);
    } 
}