- Home /
Litjson autoformat
I was fighting with litsjson quite a while, but now everything is perfect, when i create file like this
currentSetting = new Setting(new RandomStats(0.25, 0.4), new RandomStats(0.66, 1.0), new RandomStats(0.66, 1.0));
File.WriteAllText(Application.dataPath + "/" + "Settings" + ".json", JsonMapper.ToJson(currentSetting));
I get everything in one line like this:
{"OnClick_Time_To_Appear":{"Min":0.4,"Max":0.25},"Static_Time_To_Appear":{"Min":1.0,"Max":0.66},"Static_Time_To_Dissappear":{"Min":1.0,"Max":0.66}}
I know there is https://jsonformatter.curiousconcept.com ,but i cant do this on android for tests, its a bit difficult for tests purpose. Is there an auto format function, or i should write it by myself?
Comment
Best Answer
Answer by AleksandrZombie · Dec 27, 2016 at 08:06 AM
you need to create a JsonWritter, and there is a property called "PrettyPrint".
https://gist.github.com/whoo24/5506804/ //see here the example
Your answer
Follow this Question
Related Questions
How to get object array from json? 0 Answers
format text block in GUI.Box 1 Answer
Separating two strings 1 Answer
Split string in C#? 1 Answer