Live data from Hacker News

Show HN: Generate React forms from JSON form schemas

github.com

21–28 of 28 posts

Re: Show HN: Generate React forms from JSON form schemas

#22

I would strongly recommend that anyone looking into something like this first look at JSON Schema[1], which is a pretty widely adopted standard. We're doing server and client validation with one set of rules, and there are lots of libraries that will clean up your data given a schema. [1] http://json-schema.org/examples.html

Shameless plug - our Iglu Central is a central repository for commonly-used JSON Schemas. It's here: https://github.com/snowplow/iglu-central

You can think of it like RubyGems.org or Maven Central but for storing vendored, versioned data schemas instead of code.

Re: Show HN: Generate React forms from JSON form schemas

#23
post #3

I'm doing something similar with serializing django forms and sending them to a react app that turns the json into a form. It's a really convenient way of doing things.

Really sorry, down voted you by mistake with a loose finger. App I use has moved the vote buttons right where I scroll.

no prob I'm here for the discussion, not the karma

Re: Show HN: Generate React forms from JSON form schemas

#24
post #21
post #3

I'm doing something similar with serializing django forms and sending them to a react app that turns the json into a form. It's a really convenient way of doing things.

Can you provide more details how do you serialize django forms?

I could have rolled my own solution but I forked this guy's repo (fork here: https://github.com/PendletonJones/remote_forms ) and updated it to work with Python3, I also stripped out some of the stuff in date related fields because the original guy was doing some weird stuff but it's a work in progress.

Edit: basically just creating a dict out of the various attributes and then passing to json.dumps()

Re: Show HN: Generate React forms from JSON form schemas

#25

Maybe I am missing something but how are they dealing with dates?

I would assume by using ISO 8601 dates which is the closest thing there is to a standard date format in JSON.

i-JSON[1] (internet JSON a/k/a interoperable JSON) has a standard date format. Not surprisingly, it's based on ISO 8601.

1: https://tools.ietf.org/html/rfc7493

Re: Show HN: Generate React forms from JSON form schemas

#28

See also tcomb-form [1] with it's tcomb-json-schema plugin [2]. We're currently using react-forms with a custom json-schema to react-forms schema conversion. [1] https://github.com/gcanti/tcomb-form [2] https://github.com/gcanti/tcomb-json-schema

tcomb is one of the most wonderful projects I have come across, and it works beautifully with a serialiser like transit-js.

In some sense it enables your program to resemble a type system and be able to easily serialise it at runtime. Kind of similar to how games are written, I believe. And with tcomb-form you can easily have a ui layer as well.

Post reply on HN