Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #16 .
Motivation
To use the metadata fields extensively, it would be very useful to be able to encode/decode the field using the
encoding/json
library (or any other JSON encoding library). This would prevent the need to step through each key of themap[string]interface{}
to populate a custom struct.Solution
This PR changes all
map[string]interface{}
usage tojson.RawMessage
. Becausejson.RawMessage
is not necessarily a JSON object (as required by 1.3.1 of the specification), this PR also adds asserts alljson.RawMessage
fields are JSON objects.Other Improvements
Hash
function for comparing struct equality when containingjson.RawMessage
.reflect.DeepEqual
does not always work if a struct containsjson.RawMessage
.Configuration
instead of a list of items.Amount.Value
utility functionFuture PR
Find a cleaner way to create a deterministic hash of any struct in
types
.