-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
map to json #18
Comments
Because {
8: "some"
} is not valid json. But {
"8": "some"
} is valid. Only string can be key. Use |
proto3 allows int32 keys in maps and proto3 says json is its standard text format. |
@awalterschulze There's no such thing as JSON object with a non-string key. http://json.org/ |
Yes I understand. Let me add some context. You can have: And allow maps with keys int32 When json does not support non-string keys And not have a plan. |
I haven't seen a spec for how proto maps are meant to appear in JSON. That's probably something to file as an issue against google/protobuf. FWIW, I don't think encoding/json is going to work with proto3 for matching the proto3 JSON spec. The encoding/json package has a fairly rigid idea of how things are meant to be rendered. We'll see, but I suspect an auxiliary |
To be clear, JSON is not the new "text format" for proto3, but rather it is a new canonical interchange format. |
Ok so if I understand correctly:
|
If by "prototext" and "compacttext" you mean the output of So there's the binary wire format, which has been around forever, and now there will be JSON too. Your second point is accurate enough. There will be a plan for the JSON output of map fields that will be consistent across all proto language implementations; I expect to wait until that is defined before modifying Go's protobuf package to support it. |
Excellent, that is what I want to hear :) On 13 March 2015 at 12:23, David Symonds notifications@github.com wrote:
|
The newly added jsonpb package (see 67cbcad) supports the official JSON output format. It includes map output. |
Add this function to all_test.go
It will fail with
json: unsupported type: map[int32]string
Is this work just not done yet or am I understanding something incorrectly or is this a bug?
I thought that json is the new text standard for proto3 and also that proto3 supports maps?
I would guess that go needs to support marshaling proto3 structures to json or am I interpreting this in the wrong way?
The text was updated successfully, but these errors were encountered: