repetere / jsonx

JSONX - Create React Elements, JSX and HTML from JSON
https://repetere.github.io/jsonx/
MIT License
171 stars 17 forks source link

What about converting JSX to JSONX ? #386

Open asgeo1 opened 3 years ago

asgeo1 commented 3 years ago

It's really neat that this library allows React components to be rendered from JSON.

But what about going the other way? i.e. starting with JSX and converting that to JSONX syntax?

I have this idea where a user writes some JSX code (perhaps in web-based GUI), and then I'd like to serialize it to JSONX, so it can be stored in a database. Then I'd be able to send it via an API to some other app, where it can be translated back to JSX and rendered.

is that possible with this or any other library?

yawetse commented 2 years ago

I think it is possible, it would probably involve taking a look at babel/typescript JSX parsers that convert JSX to React.CreateElement etc - updating the transpiler to JSONX

I might tinker around with this later