c# - SimpleJSON Unity Exception: Error deserializing JSON. Unknown tag: 123 -


i'm getting error when accessing data json file.

i'm trying follow following tutorial: http://wiki.unity3d.com/index.php/simplejson

and created test.json file, want extract data containing:

{     "version": "1.0",     "data": {         "samplearray": [             "string value",             5,             {                 "name": "sub object"             }         ]     } } 

using following code in unity:

void loadfiles() {      fileinfo f = m_info[0]; //array of files in folder     // had foreach loop here, wanted specify file testing before tried parse through 1 of own      print("i found : " + f);     var n = jsonnode.loadfromfile(f.fullname);     var versionstring = n["version"].value;        // versionstring string containing "1.0"     var versionnumber = n["version"].asfloat;      // versionnumber float containing 1.0     var name = n["data"]["samplearray"][2]["name"];// name string containing "sub object"     print("vs=" + versionstring + " vn=" + versionnumber + " name=" + name); } 

and unknown tags, gather source :

public static jsonnode deserialize(system.io.binaryreader areader)     {         jsonbinarytag type = (jsonbinarytag)areader.readbyte();         switch(type)         {         case jsonbinarytag.array:         {             int count = areader.readint32();             jsonarray tmp = new jsonarray();             for(int = 0; < count; i++)                 tmp.add(deserialize(areader));             return tmp;         }         case jsonbinarytag.class:         {             int count = areader.readint32();                             jsonclass tmp = new jsonclass();             for(int = 0; < count; i++)             {                 string key = areader.readstring();                 var val = deserialize(areader);                 tmp.add(key, val);             }             return tmp;         }         case jsonbinarytag.value:         {             return new jsondata(areader.readstring());         }         case jsonbinarytag.intvalue:         {             return new jsondata(areader.readint32());         }         case jsonbinarytag.doublevalue:         {             return new jsondata(areader.readdouble());         }         case jsonbinarytag.boolvalue:         {             return new jsondata(areader.readboolean());         }         case jsonbinarytag.floatvalue:         {             return new jsondata(areader.readsingle());         }          default:         {             throw new exception("error deserializing json. unknown tag: " + type);         }         }     } 

i'm falling way through switch, .value or .asfloat should hit case statements. idea what's going on, code old unity 5.0 ?

it seems under false pretenses, json file xml, text, seems not, or @ least assumed binary simplejson when reading files. tried writing "text" file, , reading , worked fine. error assumed data in examples text.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -