Hi Eric,
I have a question regarding replacing the value in nested JSON body. i am using c# Fiddler script to modify the value of nested json . for e.x:
i have below nested JSON body
{
"ab":
{
"sz":1,
"rm":
{
"av":2,
"de":1,
"k":[1,
[4,
{"dn":"ab","only":"ok","pow":0,"pr":"https"
}
]
}}}]
i have used below c# script to modify the value of key "de" from 1 to 11 as
var sbody = oSession.GetResponseBodyAsString();
Fiddler.WebFormats.JSON.JSONParseResult oJSON;
oJSON = (Fiddler.WebFormats.JSON.JSONParseResult)Fiddler.WebFormats.JSON.JsonDecode(sbody);
var oObj = oJSON.JSONObject as Hashtable;
var val = ((Hashtable) oObj["ab"]);
var val1 = ((Hashtable) val["rm"]);
var oParams = val1["de"];
var value1 = 11;
sbody = sbody.Replace(oParams.ToString(), value1.ToString());
oSession.utilSetResponseBody(sbody);
After this what i see in Fiddler is that value for key "de" is got replaced by 11.
but in my whole JSON body wherever 1 is present, that also got replaced by 11. in above JSON body value of "sz" and "k" also got replaced. New json after modification is now:
{
"ab":
{
"sz":11,
"rm":
{
"av":2,
"de":11,
"k":[11,
[4,
{"dn":"ab","only":"ok","pow":0,"pr":"https"
}
]
}}}]
i just want key "de" to be replaced as 11.
Could you please help me, where i am doing wrong?