I have to represent in JSON null Integer
in this way score:
. Show name of the attribute and empty space if Integer
is null. Now if Integer
is null, then JSON doesn't show attribute. Is it possible to do it with Integer
?
CodePudding user response:
It is not possible to leave a property value empty in JSON
.
The possible value type for the fields are:
Set your variable to something distinctable like -1 or something.
CodePudding user response:
JSON represents data as name/value pairs. There must be a value present if the name is present. See JSON.org for the complete syntax.
A null can be represented by specifying null ...
{name: "Steve", score : null}
... or by omitting the name 'score' from the JSON ...
{name : "Steve"}