问题描述:

Im writing a program with Unity and I need to add GameObject.transform to a dictionary so I use this code....

Dictionary<string,object> dict=new Dictionary<string,object>();

dict["position"]=gameObject.transform.position;

Then later i convert the Dictionary to a Json string

string jsn=Json.Serialize(dict);

When you look at the jsn string, the position is converted to only one or two decimal places, this cause small numbers to be truncated to zero giving me lots of headache.

Is there a way to tell Json to increase the number of decimal places it uses when converting floating point to a Json string?

Thanks Very much!

网友答案:

Json format badly works with a float numbers. Create your own class to work with vectors, where the double type is used, and convert it to json. Good luck!

相关阅读:
Top