-
Notifications
You must be signed in to change notification settings - Fork 57
feat: Enhance VariableEditor to support BigNumber type handling #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments; Additionally, you should to add it into the dev-server too
https://github.com./microlinkhq/react-json-view/blob/main/dev-server/src/index.js#L199
I've completed the requested changes. Is there anything else that needs to be added? |
@Suntgr sorry I just reviewed right now, It seems great however test are broken in the main repo and that is blocking this. Fixing tests should be addressed first, appreciate if you can open a new PR for that. |
177049e
to
86c14ce
Compare
|
||
if (parent_type === 'array_group' && index_offset) { | ||
variable.name = parseInt(variable.name) + index_offset | ||
} | ||
if (!variables.hasOwnProperty(name)) { | ||
if (!Object.prototype.hasOwnProperty.call(variables, name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Suntgr what's the motivation for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variables might be a special object (like a json-bigint instance) that either doesn't inherit methods from Object.prototype, or has its hasOwnProperty method overridden/deleted.
example:
const JSONbig = require('json-bigint')
<JsonViewer
bigNumber={BigNumber}
src={{a: JSONbig.parse('{"c": 900719977777777999999999123}')}}
...
// following code is to make a best guess at | ||
// the type for a variable being submitted. | ||
|
||
// we are working with a serialized data representation | ||
input = input.trim() | ||
try { | ||
input = JSON.stringify(JSON.parse(input)) | ||
input = structuredClone(input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great
Thank you for reviewing and merging the PR! I noticed your comment about the broken tests. Since the PR has been merged, would you still like me to create a new PR to address the test issues? |
bigNumber
property toReactJsonView
andVariableEditor
components.JsonBigNumber
component for rendering BigNumber values.parseInput
andstringifyVariable
functions to handle BigNumber parsing and stringification.toType
utility function to recognize BigNumber instances.bigNumber
property and its usage.This update improves the precision handling of numbers in the application.