I keep trying to override values inside my JObject (i'm reciving it from web appliaction, so it can be different). I tried to use for loop, but i don't know how to iterate with JObject. Foreach is useless because i can't edit values inside my JObject.
This is my attempt:
public JObject TranslateJson(string jsonString, LanguageCharset languageCharset)
{
JObject json = JObject.Parse(jsonString);
for ( int i = 0; i > json.Count; i++)
{
json[i].Value = "test"; //Compiler Error CS1656
}
return json;
}
#Update1
public JObject TranslateJson(string jsonString, LanguageCharset languageCharset)
{
JObject json = JObject.Parse(jsonString);
foreach (var x in json)
{
json[x.Key] = "test";
}
return json;
}
#Update2
Part of json:
{
"common": {
"appName": "[App name] Web",
"other": "other",
"others": "others",
"dateRange": {
"start": "Date from",
"end": "Date to"
},
"sidebar": {
"dashboard": "[App name] dashboard",
"violations": {
"list": "Infringement list",
"timeline": "Activities and infringements"
},
"drivers": "Driver list",
"profile": "Profile",
"settings": "Settings",
"logout": "Sign out"
},
"tariff": {
"name": {
"CZ": "Czech tariff",
"RO": "Romanian tariff",
"DE": "German tariff",
"GB": "British tariff",
"LT": "Lithuanian tariff",
"DK": "Danish tariff",
"PL": "Polish tariff",
"BE": "Belgian tariff",
"CH": "Swiss tariff",
"FR": "French tariff",
"LU": "Luxembourgish tariff",
"SE": "Swedish tariff",
"HU": "Magyar tariff"
[..] (more nestings)
#Update 3
Example input json:
{
"weapons":
{
"axe": "axe",
"sword": "sword" },
"tools":
{
"saw": "saw"
}
}
Example output:
{
"weapons":
{
"axe": "translated",
"sword": "translated" },
"tools":
{
"saw": "translated"
}
}
Why only transladed? Because when i can to overwrite value inside any nest of that json structure, i just can call my transtalion function.