Search code examples
elflatbuffers

Is there an expression language to query from flatbuffers (using JAVA)?


I have a generated flatbuffers object in Java. I need to query for a field at runtime based on user input. Is there a way to do that?


Solution

  • There is currently no way to dynamically query fields in Java, you have to know the field's name statically to retrieve its value. So best you can do is if (user_input == "field") return obj.field().

    There is a way to find out what fields are in a schema dynamically, by inspecting a binary schema file (which can be generated with flatc --schema myschema.fbs). Sadly, there is no reflection helper code in Java yet that will allow you to use that information to read an actual field (C++ only so far).