This is a migrated thread and some comments may be shown as answers.

Fiddler access nested json to modify

1 Answer 393 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Denni
Top achievements
Rank 1
Denni asked on 03 Oct 2018, 08:57 PM

i somehow canĀ“t reach the objects in a nested json. I easily can reach the element test, but how to reach this_month inside "stats"? this is my json:

 

{"test":"OK","stats":{"this_month":"1653","this_week":"1653"}}     

1 Answer, 1 is accepted

Sort by
0
Denni
Top achievements
Rank 1
answered on 03 Oct 2018, 09:00 PM

sorry, accidentialy posted. here is my code:

var oResponseBody = oSession.GetResponseBodyAsString();
       JSON.JSONParseResult oJSON = JSON.JsonDecode(oResponseBody) as JSON.JSONParseResult;
       Hashtable oObj = oJSON.JSONObject as Hashtable;
 
       oObj["stats"]["this_month"] = "changed";
 
 
 
 
        var modBytes = Fiddler.WebFormats.JSON.JsonEncode(oObj);
 
       // Convert json to bytes, storing the bytes in request body
       var mod = System.Text.Encoding.UTF8.GetBytes(modBytes);
       oSession.ResponseBody = mod;
Tags
Fiddler Classic
Asked by
Denni
Top achievements
Rank 1
Answers by
Denni
Top achievements
Rank 1
Share this question
or