What I want:
To add a property in JSON file in a specific place (for this case I want to add {"name2":"Tom} after {"name":"Andrew"} ) without changing its format (empty new lines)
Current JSON
{
"Profiles": [
{
"Properties": {
"color": "blue",
"shape": "circle",
"fruit": "apple",
"name": "Andrew",
"username": "ad11",
"Password": "pass",
"country": "France",
"region": "Europe"
}
}
]
}
Current code
var json = File.ReadAllText(path);
var Jobect = JObject.Parse(json);
Jobect["Profiles"][0]["Properties"]["name2"] = "Tom";
File.WriteAllText(path, Jobect.ToString());
Resulted JSON
{
"Profiles": [
{
"Properties": {
"color": "blue",
"shape": "circle",
"fruit": "apple",
"name": "Andrew",
"username": "ad11",
"Password": "pass",
"country": "France",
"region": "Europe",
"name2": "Tom"
}
}
]
}
Desired JSON
{
"Profiles": [
{
"Properties": {
"color": "blue",
"shape": "circle",
"fruit": "apple",
"name": "Andrew",
"name2": "Tom,
"username": "ad11",
"Password": "pass",
"country": "France",
"region": "Europe"
}
}
]
}
In conclusion. How can I add a property in JSON file in a specific place and without change its format?