You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Go, using the above JSON Schema with quicktype currently generates code using the string type, where []byte is actually correct because json Marshal/Unmarshal will correctly base64 encode/decode the payload into the byte array (where as string will leave the base64 string as-is).
Description
I'm trying to interop between a TypeScript component and a Go component, however there is no way to get Go generated code to use a byte array type []byte where I need it.
Current Behaviour / Output
Current Go type is string
Proposed Behaviour / Output
Desired Go type is []byte
Solution
Solution would be for JSON Schema fields which have a string type, to check if contentEncoding and contentMediaType is defined as above, and then use the []byte type.
The text was updated successfully, but these errors were encountered:
Context (Input, Language)
If you have binary data (e.g. TypeScript ArrayBuffer) and you want to store it in a JSON document, the recommended JSON Schema is:
(this is per https://json-schema.org/understanding-json-schema/reference/non_json_data )
In Go, using the above JSON Schema with quicktype currently generates code using the
string
type, where[]byte
is actually correct because json Marshal/Unmarshal will correctly base64 encode/decode the payload into the byte array (where as string will leave the base64 string as-is).Description
I'm trying to interop between a TypeScript component and a Go component, however there is no way to get Go generated code to use a byte array type
[]byte
where I need it.Current Behaviour / Output
Current Go type is
string
Proposed Behaviour / Output
Desired Go type is
[]byte
Solution
Solution would be for JSON Schema fields which have a
string
type, to check if contentEncoding and contentMediaType is defined as above, and then use the[]byte
type.The text was updated successfully, but these errors were encountered: