2

I want to convert a JSON file into flatbuffers file (serialize JSON data to flatbuffers data). I already created flatbuffers schema but I do not know where to go from here. The documentation is not clear. It does not contain much detail.

Matthew L.
  • 37
  • 4

1 Answers1

1

Did you read the tutorial? There is a whole section on "Using flatc as a JSON Conversion Tool" with examples.

Moop
  • 3,414
  • 2
  • 23
  • 37
  • You have an array of "Main" objects, there can only be a single root object. – Moop Sep 11 '22 at 19:16
  • You can only have a single root object, so your json should be something like: { "tests": { "aa": "Test1", "bb": "Test2", "cc": "Test3", "dd": "Test4", "ee": "Test5" }, "extras": ["test1", "test2", "test3", "test4"] }, – Moop Sep 11 '22 at 19:26
  • You need another root type in that case, if you have multiple "Main" objects. Do something like: table thisIsRoot { mains:[Main];} root_type thisIsRoot; That is a single object that contains N `Main` objects in the vector. – Moop Sep 11 '22 at 19:52