Version 0.3.1
JSON-Cadence is a data interchange format used to represent Cadence values as language-independent JSON objects.
This format includes less type information than a complete ABI, and instead promotes the following tenets:
- Human-readability - JSON-Cadence is easy to read and comprehend, which speeds up development and debugging.
- Compatibility - JSON is a common format with built-in support in most high-level programming languages, making it easy to parse on a variety of platforms.
- Portability - JSON-Cadence is self-describing and thus can be transported and decoded without accompanying type definitions (i.e. an ABI).
Values
Void
_10{_10 "type": "Void"_10}
Example
_10{_10 "type": "Void"_10}
Optional
_10{_10 "type": "Optional",_10 "value": null | <value>_10}
Example
_16// Non-nil_16_16{_16 "type": "Optional",_16 "value": {_16 "type": "UInt8",_16 "value": "123"_16 }_16}_16_16// Nil_16_16{_16 "type": "Optional",_16 "value": null_16}
Bool
_10{_10 "type": "Bool",_10 "value": true | false_10}
Example
_10{_10 "type": "Bool",_10 "value": true_10}
String
_10{_10 "type": "String",_10 "value": "..."_10}
Example
_10{_10 "type": "String",_10 "value": "Hello, world!"_10}
Address
_10{_10 "type": "Address",_10 "value": "0x0" // as hex-encoded string with 0x prefix_10}
Example
_10{_10 "type": "Address",_10 "value": "0x1234"_10}
Integers
[U]Int
, [U]Int8
, [U]Int16
, [U]Int32
,[U]Int64
,[U]Int128
, [U]Int256
, Word8
, Word16
, Word32
, or Word64
Although JSON supports integer literals up to 64 bits, all integer types are encoded as strings for consistency.
While the static type is not strictly required for decoding, it is provided to inform client of potential range.
_10{_10 "type": "<type>",_10 "value": "<decimal string representation of integer>"_10}