I tryed to read a json file, edit it and then save it again, everything works fine except the order of the values in the new json file is wrong.
Here a part of the Original Json file:
"files": [
{
"name": "Game.cfg",
"sections": [
{
"name": "Chat",
"settings": [
{
"name": "ChatX",
"value": "44"
},
{
"name": "ChatY",
"value": "74"
},
{
"name": "Transparency",
"value": "0.0000"
}
]
},
and here the the same part in the new json file i create:
"files": [
{
"sections": [
{
"settings": [
{
"name": "ChatX",
"value": "44"
},
{
"name": "ChatY",
"value": "74"
},
{
"name": "Transparency",
"value": "0.0000"
}
],
"name": "Chat"
},
and here the code if needed:
string filename = filesource;
var res = JsonConvert.DeserializeObject<PersistentSettings>(File.ReadAllText(filename));
List<PersistentSettings> pers = new List<PersistentSettings>();
pers.Add(res);
string json = JsonConvert.SerializeObject(pers, Formatting.Indented);
//write string to file
File.WriteAllText("test.json", json);
like i said it works just not as it should, anyone got an idea why?