jamescourtney / FlatSharp

Fast, idiomatic C# implementation of Flatbuffers
Apache License 2.0
497 stars 50 forks source link

Json serialization support? #288

Closed cove closed 2 years ago

cove commented 2 years ago

Hi!

Any thoughts on supporting serialization to json as well or any suggestions on where to start? e.g. flatc's --cs-gen-json-serializer option.

The use case I have is that my game uses gRPC+flatc, but I have low code admin tools that only understand REST/json and need to use the API too.

jamescourtney commented 2 years ago

This is something I've considered doing. However, the thing I always come back to is that there are already a ton of great JSON libraries available for .NET (unsure about Unity -- perhaps you can educate me!), and I'm not sure what I could do better than them.

Serializing to JSON should be pretty straightforward. Just a see-thing-write-thing approach. Parsing from JSON would be considerably more difficult because of the additional grammar.

cove commented 2 years ago

Oh I don't actually need to go from JSON to back to FlatBuffers encoding actually. I just need to have the same interface to the objects so that I don't need to duplicate the schema, maintaining one for json and another for FlatBuffers. What do think?

cove commented 2 years ago

I think what I want actually is Microsoft.AspNetCore.Grpc.HttpApi, but with FlatBuffers support. (I'm not a C#/.Net expert (coming more from UE/C++) so don't know my way around the frameworks that well.)

cove commented 2 years ago

Closing this out since it's probably better handled in https://github.com/grpc/grpc-dotnet/issues/167 and https://github.com/grpc/grpc-dotnet/issues/1687