Skip to content

Import JSON Schema as IDL #2

Closed

Description

@TJKoury

What
Add a flatc importer for JSON Schema that reconstructs the same IR you’d get from parsing the original .fbs, when the JSON Schema was produced by FlatBuffers’ exporter.

Why
Complete the round-trip (IDL → JSON Schema → IR) to reduce friction for teams that start with JSON Schema and to enable deterministic CI tests.

How
• New mode: flatc --schema-in path/to/schema.json [--lang ...]
• Prefer x-flatbuffers-* hints emitted by the exporter.
• Map JSON Schema → FlatBuffers:
• type: object → table; x-flatbuffers-struct: true → struct
• type: array → vector
• integer/string enums → enum (respect x-flatbuffers-enum-base)
• oneOf (+ discriminator/x-flatbuffers-union) → union
• $defs/$ref → named types/refs; required → (required); default → field default
• Map-like additionalProperties with x-flatbuffers-map: true
• Type inference from minimum/maximum:
• Choose narrowest signed/unsigned scalar (byte…ulong) covering bounds
• number defaults to double unless x-flatbuffers-float:"float"
• Clear diagnostics for unmappable features (e.g., complex allOf, patternProperties).

Done when
• Importing JSON Schemas generated by flatc yields IR ≡ importing the source .fbs.
• Minimal-width integer/unsigned types are inferred correctly from bounds.
• Unions/enums/structs/tables and FB attributes round-trip exactly.
• Helpful errors for unsupported constructs.
• Tests: golden round-trip corpus, numeric-inference property tests, unions/maps cases.

Activity

  1. linked a pull request that will close this issue2 import json schema as idl #3on Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions