flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

JSON: Support vectors of Unions

Open dalnew opened this issue 7 years ago • 14 comments

I would like to get vectors of unions supported in JSON. This enables easier debugging of serialized C++ (and other languages) flatbuffers as well as enabling simple JSON parsing for quick manual edits of Flatbuffers. Right now you'll get the error: error: Vectors of unions are not yet supported in all the specified programming languages.

C++ PRs: https://github.com/google/flatbuffers/issues/5002 https://github.com/google/flatbuffers/issues/4143

dalnew avatar Feb 01 '19 00:02 dalnew

Can you make a PR for this?

aardappel avatar Feb 01 '19 00:02 aardappel

This issue has been automatically marked as stale because it has not had activity for 1 year. It will be automatically closed if no further activity occurs. To keep it open, simply post a new comment. Maintainers will re-open on new activity. Thank you for your contributions.

stale[bot] avatar Feb 01 '20 00:02 stale[bot]

unstaling this issue.

ghost avatar Feb 05 '20 15:02 ghost

Maybe this should be re-opened? The points made in the OP still stand, and make a lot of sense IMO 🙂

jedrichards avatar Jul 29 '21 10:07 jedrichards

It seems this github bot is makingit super hard to keep an issue open :P I'd love to get vectors of unions superted in json as well. I'm not super familliar with flatbuffers internals to add it myself yet, maybe in a few month if no one take on it :)

sistr22 avatar Aug 24 '21 08:08 sistr22

Do we need to remove the stale label too, to stop the bot immediately closing this again?

jedrichards avatar Aug 31 '21 08:08 jedrichards

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

github-actions[bot] avatar Mar 01 '22 20:03 github-actions[bot]

This enables easier debugging

"Easier"? What's the harder option?

I have a binary FlatBuffers file plus the definitions. How can I read the file if I can't convert it to JSON? Is the only option really to write a C++ application in which I read the file and print out the contents?

(Thanks for any tips. It's my first encounter with FlatBuffers.)

darabos avatar Sep 14 '22 13:09 darabos

Yep, I think you're correct - if your schema contains vectors of unions then indeed the only way to inspect the contents of a file is to write a small application using one of the auto-generated APIs. You're not limited to C++ there though - I found it quicker to whip up a small TypeScript script for example.

I'd also like to know if there's any easier way though, but I suspect not 😅

jedrichards avatar Sep 15 '22 13:09 jedrichards

Awesome, thanks! I'll give TypeScript a try!

darabos avatar Sep 15 '22 14:09 darabos

Being able to generate a JSON with a schema which contains vectors of unions would be really helpful and save me a lot of time.

While of course writing a small application would be possible i don't understand why this is not built in. Is it lack of time or are there more fundamental problems? Is anything wrong with the PRs from @dalnew ?

ridilculous avatar Dec 08 '22 11:12 ridilculous

Those PRs linked at the top of the issue are about adding vectors of unions to the C++ language support, not JSON. If that's what you mean?

At work we've developed quite a few more schemas since I commented on this issue, and the prob continues to haunt us. At this stage I'd recommend avoiding vectors of unions in schemas because of it - being able to quickly view the contents of a FB for debug purposes in JSON is too valuable.

jedrichards avatar Dec 08 '22 11:12 jedrichards

Ah, i see. Thanks a lot for clarifying this!

Is there any chance that the initial question of the OP, supporting vectors of unions with JSON, will make it into the official release or is the demand just not high enough? I'm new to flatbuffers and am wondering if supporting vector of union is considered a failed experiment at this stage or if there's just no clear solution for JSON in sight because a lot of different approaches would be possible.

At the company we're using JSON (and yaml) not only for debugging output but also as a user interface for new functionality for which a real UI doesn't exist yet.

ridilculous avatar Dec 08 '22 11:12 ridilculous

@ridilculous it's totally a feature worth supporting, but this project runs for the most part on volunteer contributions, and it seems no-one has picked this up.

aardappel avatar Dec 08 '22 17:12 aardappel