JSON Fundamentals
JavaScript Object Notation, or JSON, is a lightweight format for storing and transporting data of most any kind. It contains "fields" of your own choosing to convey strings, numbers, boolean values, other JSON objects, and arrays of values:
{
"temp": 34.5,
"skies": "cloudy",
"windy": true
}
You can learn more about using JSON and its syntax in this online tutorial.
How the Notecard works with JSON
As you work with the Notecard API, there are a few behaviors and caveats to keep in mind:
-
If using Notefile Templates and a structure field is
""
(string),0
(int),0.0
(float), orfalse
(bool) then that field will be omitted from all JSON requests and will be omitted from JSON responses. In the case of responses, the absence of an expected field should be interpreted as0
or empty. -
Representation of whole numbers will appear in JSON without a decimal point.
-
Integers greater than
2^31
and less than-2^31
, while generally supported, are technically "Undefined Behavior" by the JSON specification and thus may be converted into floating point numbers by some implementations. -
Sending JSON from one part of the software or service to another, and getting that JSON back from the software or service, does not guarantee the order of fields or the presence of any whitespace.
-
Although tabs,
CR
, andLF
characters are technically allowable whitespace in JSON, they are not allowed in Notecard requests or bodies and will never be placed within Notecard responses. The Notecard uses the ndjson technique of new line-delimited JSON. -
The Notecard JSON libraries do support UTF-8, but there may be language representation limitations due to the constraints of JSON within embedded systems. Multi-byte characters are not supported, but if multi-byte characters are required, you must use a binary transfer mechanism or a different JSON parser.