Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to keep JSON readable for some implementations #35

Open
philippgille opened this issue Nov 26, 2018 · 0 comments
Open

Add option to keep JSON readable for some implementations #35

philippgille opened this issue Nov 26, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@philippgille
Copy link
Owner

Currently, when JSON is used as MarshalFormat, it will always be converted to []byte. This makes the result unreadable as a human, unless interpreted as / converted back to string. So for example when using DynamoDB, and a struct is marshalled into a JSON {"Foo":"bar"}, saved to DynamoDB with gokv, and then you look at the value via the AWS console, it's just eyJGb28iOiJiYXIifQ==, the Base64 encoding of the JSON string.

That's because in the dynamodb implementation we use a awsdynamodb.AttributeValue for the value where we assign the value to a field B, which is for []byte, and has the Base64 encoding described in the comment:

// An attribute of type Binary. For example:
//
// "B": "dGhpcyB0ZXh0IGlzIGJhc2U2NC1lbmNvZGVk"
//
// B is automatically base64 encoded/decoded by the SDK.
B []byte `type:"blob"`

In this case, we could look at the option provided by the package user and instead of B, use S and assign the plain JSON string to it.

This should also be done in a similar way for other implementations. It only makes sense for some of them though!

@philippgille philippgille added the enhancement New feature or request label Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant