1. 8

  2. 3

    At my workplace we use Zod for a similar sort of thing. It works especially well since some of our untyped data comes from non-JSON sources, e.g. CSV, database queries.

    1. 2

      Interesting, but it isn’t clear from the Readme how it’s doing the same thing? The section on type inference doesn’t seem to mean the same thing (https://github.com/colinhacks/zod#type-inference).

      The purpose of this library is more oriented around exploring existing data rather than being used to define schemas for use in your application development.

      Maybe I’m misunderstanding zod though.

    2. 2

      While I’m sure there are more libraries that do this kind of thing, they’re kind of hard to find! The JSON Schema project lists a few of them: https://json-schema.org/implementations.html#from-data.

      1. 2

        Surely you’ve seen Quicktype on that list, right? It’s one of my go-to options!

        1. 1

          I didn’t actually find the json-schema list until after I wrote this library. But yes it looks very good!

          One consideration I’m not sure Quicktype handles (at a glance) is efficiently dealing with arbitrarily large inputs. For example, if I load 30MB of logs into DataStation, I still want to be able to show the inferred schema. I wasn’t able to do this (JavaScript would throw a stack exception) until I added sampling logic to this library.

      2. 2

        String or number or number or number?

        1. 2

          Oops. That’s a screenshot from an earlier version with that bug. I’ll have to fix that. :) Thanks

          1. 2

            The screenshot is fixed now. :) Thanks!