Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert recursively converts the input object into a MSGP representation.
Strings are converted using the following heuristic:
- if the string is not valid utf-8, it is passed through as a byte array without modification. - if the string is a valid ndau address, it's represented as a string. - if the string is valid padded base64 in the standard encoding, it is decoded and represented in the MSGP as a byte array. - otherwise, it is assumed to be a string, and represented as a string.
This is primarily intended to assist conversion from JSON to MSGP, so certain conversions such as structs are intentionally excluded. If you have a struct, use `msgp.Marshal` directly.
func ConvertStream ¶
ConvertStream reads JSON from `in` and copies it as MSGP to `out` until EOF.
Strings are converted using the following heuristic:
- if the string is not valid utf-8, it is passed through as a byte array without modification. - if the string is a valid ndau address, it's represented as a string. - if the string is valid padded base64 in the standard encoding, it is decoded and represented in the MSGP as a byte array. - otherwise, it is assumed to be a string, and represented as a string.
Numeric valuse need extra help to know their types. Use the typeHints map for that.
- if all "Fee" variables are to be encoded as int64, and "ChangeOn" as uint64, then use: typeHints = {"Fee": []string{"int64"}, "ChangeOn": []string{"uint64"}}
- if there are blobs of json without names, yet there are arrays of differing numeric types, such as: [[0,1],[-2,3],[4,5]], then use: typeHints = {"": []string{"int64", "uint64"}}