I have Json String which is in form of JsonArray as below:
[{“key1”:“value1”}, {“key2”:“value2”}]
and I want to add the new Json hardcoded by ourselves like below Json:
{“key3”:“value3”} into the above Json String.
How I want is:
{
“object”:[{“key1”:“value1”}, {“key2”:“value2”}],
“key3”:“value3”
}
Please some one help me here, as it is high priority work
Parvathy
(PS Parvathy)
2
Hi @ahmed.faisal
Assign-> existingJsonArray = "[{""key1"":""value1""}, {""key2"":""value2""}]"
Assign-> newJsonObject = "{""key3"":""value3""}"
Assign-> combinedJson = Newtonsoft.Json.JsonConvert.SerializeObject(New Newtonsoft.Json.Linq.JObject(New Newtonsoft.Json.Linq.JProperty("object", Newtonsoft.Json.Linq.JArray.Parse(existingJsonArray)), New Newtonsoft.Json.Linq.JProperty("key3", Newtonsoft.Json.Linq.JObject.Parse(newJsonObject)("key3"))))
existingJsonArray, newJsonObject, combinedJson are of DataType System.String.
Hope it helps!!
It Helped, Thanks a lot!!
1 Like
Parvathy
(PS Parvathy)
4
Hi @ahmed.faisal
Hope your query is resolved. If yes, please mark my post as solution to close the loop or if you have any questions, I’m happy to help.
Regards