LitJSON Library for format FLOAT / DOUBLE issue LitJSON Library for format FLOAT / DOUBLE issue json json

LitJSON Library for format FLOAT / DOUBLE issue


Had the same problem, finally found a solution.Add these lines of code before your "ToObject" / "ToJson"

JsonMapper.RegisterExporter<float>((obj, writer) => writer.Write(Convert.ToDouble(obj)));JsonMapper.RegisterImporter<double, float>(input => Convert.ToSingle(input));


I wanted to comment but my reputations are < 50.

I was using LitJson in Unity3D (scripting language Mono C#). I faced the same problem while parsing the json to an object which have lot of float mebmbers. I have added float support to LitJson library. Let me know if you still require this.


From what I have seen from their source code on Github the library supports Double and not Single

extracts from Jsondata.cs from their library

#region Fieldsprivate IList<JsonData> inst_array;private bool inst_boolean;private double inst_double;private int inst_int;private long inst_long;private IDictionary<string, JsonData> inst_object;private string inst_string;private string json;private JsonType type;