[GH-ISSUE #991] The long value was accidentally changed after using the scripting tool #987

Open
opened 2026-03-03 19:23:33 +03:00 by kerem · 2 comments
Owner

Originally created by @lyhsgit2015 on GitHub (Sep 14, 2021).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/991

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

Proxyman 2.30.0

macOS Version? (Ex. mac 10.14)

mac 11.5.1

Steps to reproduce

Use scripting function to make the response have a numeric field longer than 11 digits, it will become a strange number
Its original value should be

image

but it becomed
image

i didn't rewrite this field on response, but did rewrite others field , why it would effect this field

Expected behavior

return the original value

Screenshots (optional)

Originally created by @lyhsgit2015 on GitHub (Sep 14, 2021). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/991 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) Proxyman 2.30.0 ### macOS Version? (Ex. mac 10.14) mac 11.5.1 ### Steps to reproduce Use scripting function to make the response have a numeric field longer than 11 digits, it will become a strange number Its original value should be ![image](https://user-images.githubusercontent.com/15918650/133186692-b732f17c-e1d2-44fd-b18e-bef7d547cb8e.png) but it becomed ![image](https://user-images.githubusercontent.com/15918650/133188275-5dcca69c-f98f-4b4e-89b9-ee29d6ea3ade.png) i didn't rewrite this field on response, but did rewrite others field , why it would effect this field ### Expected behavior return the original value ### Screenshots (optional)
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 14, 2021):

Thanks for the screenshot. I suppose that it's an issue when parsing the JSON String to JSON Object 👍 I will fix and sent you a beta build this week 👍

<!-- gh-comment-id:918853152 --> @NghiaTranUIT commented on GitHub (Sep 14, 2021): Thanks for the screenshot. I suppose that it's an issue when parsing the JSON String to JSON Object 👍 I will fix and sent you a beta build this week 👍
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 14, 2021):

Hey @lyhsgit2015 I investigate your issue. Unfortunately, it's a limitation of the JavascriptCore, which is used by the Scripting Tool behind the scene.

Basically, when I pass the Swift Dictionary Object to JavascriptCore and receive the result. JavascriptCore automatically casts your huge number to float. As a result, it displays 1.43......e+18.

I tried some solutions but it doesn't work well 😿

To workaround, I suggest using response.bodyFilePath.
For example:

function onResponse(context, url, request, response) {
 
  response.headers["Content-Type"] = "application/json";
  response.bodyFilePath = "~/Desktop/my_response.json";
 
  // Done
  return response;
}

By doing this way, you have to modify the response on the file at "~/Desktop/my_response.json", but it would fix the problem 👍

Ref: https://docs.proxyman.io/scripting/snippet-code#map-a-local-file-to-responses-body-like-map-local-tool-proxyman-2-25-0

<!-- gh-comment-id:918905741 --> @NghiaTranUIT commented on GitHub (Sep 14, 2021): Hey @lyhsgit2015 I investigate your issue. Unfortunately, it's a limitation of the JavascriptCore, which is used by the Scripting Tool behind the scene. Basically, when I pass the Swift Dictionary Object to JavascriptCore and receive the result. JavascriptCore automatically casts your huge number to float. As a result, it displays `1.43......e+18`. I tried some solutions but it doesn't work well 😿 To workaround, I suggest using `response.bodyFilePath`. For example: ```js function onResponse(context, url, request, response) { response.headers["Content-Type"] = "application/json"; response.bodyFilePath = "~/Desktop/my_response.json"; // Done return response; } ``` By doing this way, you have to modify the response on the file at `"~/Desktop/my_response.json"`, but it would fix the problem 👍 Ref: https://docs.proxyman.io/scripting/snippet-code#map-a-local-file-to-responses-body-like-map-local-tool-proxyman-2-25-0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#987
No description provided.