JSON: Support vectors of Unions
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
Can you make a PR for this?
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.
unstaling this issue.
Maybe this should be re-opened? The points made in the OP still stand, and make a lot of sense IMO 🙂
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 :)
Do we need to remove the stale label too, to stop the bot immediately closing this again?
This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.
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.)
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 😅
Awesome, thanks! I'll give TypeScript a try!
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 ?
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.
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 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.