In Fiddler, I have a response body (application/json) that I convert into an Object using eval() (if there is a better way please let me know) to perform some checks. Now I want to convert several parts (but not all parts) of the object back into a string and save them to seperate files. How would I do this in Jscript?
I have tried using the ToString() method but it only returns [object Object]. Any ideas?
I had the same question and I asked Fiddler Forum about it. From the answer, I cooked this FiddlerScript (JScript) to answer yours:
var sInput = '{"a" : 1, "b" : [2, 3, 4]}';
var oJSON = Fiddler.WebFormats.JSON.JsonDecode(sInput);
FiddlerApplication.Log.LogFormat('input: {0}', sInput);
FiddlerApplication.Log.LogFormat('oJSON: {0}', oJSON.ToString());
FiddlerApplication.Log.LogFormat('oJSON["a"]: {0} (expected: 1)', oJSON.JSONObject["a"]);
FiddlerApplication.Log.LogFormat('oJSON["b"] : {0} (expected: 2)', oJSON.JSONObject["b"][0]);
I hope this will help after half a year...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With