Reputation: 10175
Can JSON values (not keys) be numbers, or do they HAVE to be strings only? So the following is valid.
{"number":"6"}
But is the following also valid?
{"number":6}
Upvotes: 1
Views: 3096
Reputation: 14436
Json values can be
See - https://www.w3schools.com/js/js_json_datatypes.asp
Upvotes: 0
Reputation: 896
It is valid JSON syntax. But beware that different programming languages will parse JSON differently..
https://www.freeformatter.com/json-validator.html
Upvotes: 2
Reputation: 1453
In JSON, 6 is the number six. "6" is a string containing the digit 6. So the answer to the question "Can json numbers be quoted?" is basically "no," because if you put them in quotes, they're not numbers anymore.
The only thing that needs to be between quotes is the property name (number).
Upvotes: 1