//Why JSON serialization is not a problemdictionary<string,int> dic =Newdictionary<string,int>(); DiC. ADD ("1",1); stringStrjson =LitJson.JsonMapper.ToJson (DIC);//that's a problem.dictionary<int,int> Dic2 =Newdictionary<int,int>(); Dic2. ADD (1,1); stringStrJson2 =LitJson.JsonMapper.ToJson (DIC2); Debug.Log (strJson2);
JSON serialization does not support structs, such as the Vector3 type in unity is not supported, so we have to transform the following
1 // Vector3 is originally a float type, but JSON does not support float type, so use double type 2 Public class Vector3obj 3 {4 Double x; 5 Double y; 6 Double Z; 7 }
- Considerations for using JSON
- -Non-numeric key value in JSON string without double quotes
- -There is a tab in JSON like \ T, which looks like a space, but because it does not pass, it needs to be removed
- -Editor with BOM header will also cause
Use of JSON serialization in Unity failed