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

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

1 Answer 458 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
asked on 25 Feb 2019, 10:06 AM

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.

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 01 Mar 2019, 12:20 PM
Hi,

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.

Regards,
Alexander
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
Tags
Fiddler Classic
Asked by
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or