Fiddler Ideas

The free web debugging proxy for any browser, system or platform.

How to call JSON methods inside fiddler script?

Hi there, what's the correct way to call:





after calling these JSON methods, fiddler says:

Variable 'JSON' has not been declared





  • David Henrry Ticona
  • Nov 21 2017
  • Under review
  • Attach files
  • Eric Lawrence commented
    21 Nov, 2017 10:54pm

    The JSON object you're trying to use is a part of the browser's Document Object model and doesn't directly exist within FiddlerScript. The .NET framework (on which FiddlerScript runs) offers a variety of JSON libraries and one of them may be your best choice.

    Having said that, Fiddler does itself have its own JSON objects; they're not optimized for FiddlerScript, however, so you might find them a little cumbersome. At the top of your script, add: 

       using Fiddler.WebFormats;
    In the code, add e.g.
    var oResponseBody = oSession.GetResponseBodyAsString();
    JSON.JSONParseResult oJSON = JSON.JsonDecode(oResponseBody) as JSON.JSONParseResult;
    Hashtable oObj = oJSON.JSONObject as Hashtable; 
    var oVal = (oObj != null) ? oObj["myObjectValue"] : null;