An error is reported when using the eval function to manipulate JSON

0 Answers 128 Views
Extensions and Customization Fiddler Classic Windows
LALA
Top achievements
Rank 1
LALA asked on 25 Nov 2021, 01:39 PM

I used the eval function in fiddlerscript to dynamically load code from the server when fiddler was opened.But when using the eval function to process JSON, the program throws an exception.code show as below:

 //Operating normally

if(oSession.uriContains('https://xxxxxx.com')){ var responseStringOriginal = oSession.GetResponseBodyAsString(); var responseJSON = Fiddler.WebFormats.JSON.JsonDecode(responseStringOriginal); responseJSON.JSONObject['data']['data1']['data2'] = 22; responseJSON.JSONObject['data']['data1']['data3'] = 1; responseJSON.JSONObject['data']['data1']['data4'][0]['type'] = 2; responseJSON.JSONObject['data']['data1']['data5'][0]['type'] = 22; var responseStringDestinal = Fiddler.WebFormats.JSON.JsonEncode(responseJSON.JSONObject); oSession.utilSetResponseBody(responseStringDestinal); }

//throw an exception
eval("if(oSession.uriContains('https://xxxxxx.com')){var responseStringOriginal=oSession.GetResponseBodyAsString();var responseJSON=Fiddler.WebFormats.JSON.JsonDecode(responseStringOriginal);responseJSON.JSONObject['data']['data1']['data2']=22;responseJSON.JSONObject['data']['data1']['data3']=1;responseJSON.JSONObject['data']['data1']['data4'][0]['type']=2;responseJSON.JSONObject['data']['data1']['data5'][0]['type']=22;var responseStringDestinal=Fiddler.WebFormats.JSON.JsonEncode(responseJSON.JSONObject);oSession.utilSetResponseBody(responseStringDestinal)}")
Under my constant testing, I found that when the program is executed to JSON containing [number], it will throw an exception. It runs normally when the statement was deleted

 

(It says that Hashtable cannot cast to StackFrame)

Thanks for help.

No answers yet. Maybe you can help?

Tags
Extensions and Customization Fiddler Classic Windows
Asked by
LALA
Top achievements
Rank 1
Share this question
or