Open
Description
When <ReactJson>
has this src
[
{
"a": "a"
"moreNestedData": {
"b": "abc",
"c": "-10"
}
}
]
and when I add onEdit and try to edit...
"a" = working good ✅ (without validation error message)
"b" = working good ✅ (without validation error message)
"c" = validation error ❌ (edit to "-20") (this is a normal string and it should be string) (why this is error?)
So my question is how does validation work, or how to disable it ?
This is seems like the type when editing... it changing to int
Thanks
Activity
[-]How does validation work?[/-][+]Bug: Type validation – Strings like "-10" are changed to int when editing[/+]Suntgr commentedon May 24, 2025
Hi! This is actually not a bug, but a feature.
When you edit a value, react-json-view automatically detects the data type. For strings like "-10" that match number patterns, you'll see two checkmarks on the right:
Top ✅: Keep as string ("-10")
Bottom ✅: Convert to detected type (integer -10)
Simply click the top checkmark to keep it as a string, or the bottom one to convert it to a number.
This gives you flexibility to choose the data type without manually adding quotes or formatting.