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

toJSON fails to marshal objects with nested objects #138

Closed
hairyhenderson opened this issue May 12, 2017 · 0 comments
Closed

toJSON fails to marshal objects with nested objects #138

hairyhenderson opened this issue May 12, 2017 · 0 comments

Comments

@hairyhenderson
Copy link
Owner

This is vaguely related to #134.

toJSON behaves badly:

$ gomplate -i '{{ "foo:\n  bar: baz\n" | yaml | toJSON }}'
2017/05/11 21:46:30 Unable to marshal object map[foo:map[bar:baz]]: json: unsupported type: map[interface {}]interface {}

However, toYAML doesn't:

$ gomplate -i '{{ "foo:\n  bar: baz\n" | yaml | toYAML }}'
foo:
  bar: baz

I think the problem is documented in the docs for json.Marshal

Map values encode as JSON objects. The map's key type must either be a string, an integer type, or implement encoding.TextMarshaler.

Obviously gpkg.in/yaml.v2 doesn't have this problem...

🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant