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

JSON formatting in C# #582

Merged
merged 6 commits into from Jul 14, 2015
Merged

Conversation

jskeet
Copy link
Contributor

@jskeet jskeet commented Jul 10, 2015

(No parsing is supported yet. Some extra reflection support was required for oneof.

@jskeet
Copy link
Contributor Author

jskeet commented Jul 10, 2015

@jtattermusch @anandolee

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jul 10, 2015

@jskeet how do you plan to support Any message in the JSON conversion?

@jskeet
Copy link
Contributor Author

jskeet commented Jul 10, 2015

Unsure as yet. I'm going to do the easier well-known types (Timestamp, Duration, Struct etc first), and hope that Java has tackled this before I have to...

}

// Now oneofs
foreach (var accessor in fields.Oneofs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So all the one ofs will appear in the JSON representation after all the other fields? Isn't that a bit odd? To me it looks like the fields should be written ordered by their field numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that code would be considerably uglier. I can try it if you want, but bearing in mind that the field numbers aren't even visible in the JSON, and oneofs already behave a bit weirdly in JSON, I think I'd prefer to keep it like this. I would expect different implementations to make different decisions on this, when it comes to ordering. (I'm sure I saw something somewhere saying that the ordering didn't matter for JSON, but I can't find it now.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to leave it like this but I'd still add a note or a todo, because the ordering is not ideal currently (even though it's allowed by proto3).

@jtattermusch
Copy link
Contributor

The code LGTM after addressing the minor issues mentioned above (adding a TODO and removing the unnecessary indexers). Feel free to merge afterwards.

- Remove the indexers in FieldAccessorTable
- Add a TODO for field ordering in oneof
jskeet added a commit that referenced this pull request Jul 14, 2015
@jskeet jskeet merged commit 9440a2a into protocolbuffers:csharp-experimental Jul 14, 2015
@jskeet jskeet deleted the csharp-json branch July 15, 2015 08:50
@jtattermusch jtattermusch mentioned this pull request Jul 16, 2015
adellahlou pushed a commit to adellahlou/protobuf that referenced this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants