How to traversal a array in JSON Response in CustomRules.js ?

2 posts, 0 answers
  1. 哲 avatar
    1 posts
    Member since:
    Feb 2019

    Posted 25 Feb 2019 Link to this post

    In CustomRules.js

    static function OnBeforeResponse(oSession: Session) {

            var responseStringOriginal =  oSession.GetResponseBodyAsString();

            var responseJSON = Fiddler.WebFormats.JSON.JsonDecode(responseStringOriginal);
            var responseJSONObject = responseJSON.JSONObject;




    There is an array in response responseJSONObject , like 

            "id": "6661370502453447944"



            "id": "333" 





    Question 1: How can I get this array's length or traversal this array?


    Question 2: How can I create an array using for loop and save the new array to the responseJSON.JSONObject?


    Question 3: Where can I find any documentation about this object "Fiddler.WebFormats.JSON", like what method and properties it have.


    I tried several ways but nothing works and I can't using the JSON.parse() function in this script.

    I also google for the documents of  this object (Fiddler.WebFormats.JSON) and found nothing.



    Thank you very much and welcome reply any infomation.

  2. Alexander
    Alexander avatar
    383 posts

    Posted 01 Mar 2019 Link to this post


    Rather unfortunately, there is no documentation for that API. Because of that, I would suggest you to use external JSON library (like JSON.NET). JSON.parse() is not available since it is from the Javascript API.

    In order to use an external library, add the .dll file to Fiddler's root directory (by default %LOCALAPPDATA%\Programs\Fiddler) and start using it in the FiddlerScript as usual.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top