use 0x1::option;
use 0x1::string;
use 0x2::simple_map;
Error if the T
is not a struct
const ErrorTypeNotMatch: u64 = 1;
Error if the json string is invalid
const ErrorInvalidJSONString: u64 = 2;
Function to deserialize a type T. The u128 and u256 types must be json String type instead of Number type
Function to deserialize a type T. If the json string is invalid, it will return None
#[data_struct(#[T])]
public fun from_json_option<T: copy>(json_str: vector<u8>): option::Option<T>
Parse a json object string to a SimpleMap If the json string is invalid, it will return an empty SimpleMap If the field type is primitive type, it will be parsed to String, array or object will be parsed to json string
public fun to_map(json_str: vector<u8>): simple_map::SimpleMap<string::String, string::String>
Serialize a value of type T to JSON string bytes.