SCALE-native JSON value #5024
Labels
api-changes
Changes in the API for client libraries
Enhancement
New feature or request
question
Further information is requested
Context
Continuation of:
JsonString
in schema vs in json #4900JsonString
toJsonValue
#5012In short, Iroha supports arbitrary JSON payloads for certain actions. In SCALE they are encoded as JSON strings (
JsonString
type), while in JSON format they are inlined as values.This is a proposal of an alternative solution: introduce as SCALE-native
JsonValue
type, encoded not as a string, but directly as an enum:this is a literal copy of
serde_json::Value
Benefits
"[{}],
characters & whitespaceJsonValue
represents fDownsides
Why it is String now
AFAIK the initial choice of string representation for JSON values is an efficiency concern: we don't want to pay for extra (de)serialization while transmitting data to/from WASM smartcontracts.
Basically, string was used as a way to have lazy encoding of data, as requested.
I think it should be possible to achieve lazy encoding in a more direct way with some sort of
Lazy<T>
container, making it both more explicit and flexible.The text was updated successfully, but these errors were encountered: