ritz078 / transform Goto Github PK
View Code? Open in Web Editor NEWA polyglot web converter.
Home Page: https://transform.tools
License: MIT License
A polyglot web converter.
Home Page: https://transform.tools
License: MIT License
HOCON is a JSON superset. Many parsers exist, including my favorites, circe-config and PureConfig.
In the left panel we can load a file like .json
from computer.
It would be awesome if I could have a CLI version of this, takes stdin, some arguments, prints result.
Editor integration could become a thing.
I tried to paste in the OpenApi schema from https://github.com/Mermade/swagger2openapi/blob/master/schemas/openapi-3.0.json, but it does not generate classes for objects deeper in the graph. Is it related to "oneOf"? Advice? Thanks!
maybe utilizing https://www.npmjs.com/package/json-to-graphql-schema ?
Probably use — https://github.com/avantcredit/gql2ts
It will be nice to have another checkbox for ES6 format for the create class of HTML to JSX in the React Section.
Maybe it's too much for the tools.
Thanks for this awesome tools 👍
warning on npm install
.
I will be busy with some other projects in coming days. This project seems to be stable in its current state but I will like to see it evolve and I will need some helping hand. Let me know if you are interested.
cc @morajabi
In the example at https://transform.now.sh/json-to-scala-case-class, it translates a JSON array to a Scala Array
. Unfortunately, Scala Array
is just a wrapper for Java arrays, which have reference equality. That means that equality between case class instances produced using this tool will not have sensible equality (because distinct arrays containing the same elements will be considered different).
A simple solution would be to switch Array
to Seq
or IndexedSeq
, which will have sensible equality.
Should we do JSON to Immutable prop types ?
If yes, I would be happy to implement it!
#[serde(rename = "Longitude")]
_longitude: f64,
should just be
#[serde(rename = "Longitude")]
longitude: f64,
thanks again. saved me a ton of time.
Willing to submit a PR if you have the plan
I guess this is two issues in one, but these are things I've noticed while trying to use it.
{
"type": 1
}
Output will give you the following struct:
#[derive(Serialize, Deserialize)]
struct RootInterface {
type: i64,
}
But it should be giving something like this:
#[derive(Serialize, Deserialize)]
struct RootInterface {
#[serde(rename = "type")]
kind: i64,
}
{
"cat dog": 1
}
#[derive(Serialize, Deserialize)]
struct RootInterface {
"cat dog": i64,
}
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.
Since we didn’t receive a CI status on the greenkeeper/initial
branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/
.
Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.
In the following example, the transformer demonstrates the following rule:
.alert-dismissible .close {
position: relative;
top: -0.75rem;
right: -1.25rem;
padding: 0.75rem 1.25rem;
color: inherit;
}
being converted into:
export const alertDismissible = css`
& .${close} {
position: relative;
top: -0.75rem;
right: -1.25rem;
padding: 0.75rem 1.25rem;
color: inherit;
}
`
This should come with a warning as, per emotions documentation:
To nest a class selector using the class generated with
css
you can interpolate it but this is strongly recommended against and should only be used in rare circumstances because it will break when used with composition.
Meaning that it'll break when trying to force specificity using cx
I think this would be a good addition.
there is a bunch of I
before all types
example:
// @flow
export type IRootObject = {
TargetUrl: null;
Success: boolean;
Result: IResult;
Error: null;
UnAuthorizedRequest: boolean;
};
it was like this:
export type RootObject = {
TargetUrl: null;
Success: boolean;
Result: Result;
Error: null;
UnAuthorizedRequest: boolean;
};
After finalizing the move to our new org, we'll design logo here.
Transforming this JSON into TypeScript interface produces the following output:
JSON:
{
"key_1": "foo",
"24_hour_volume": 123.123,
"key_2": "bar"
}
TypeScript:
interface RootInterface {
key_1: string;
24_hour_volume: number;
key_2: string;
}
This produces an error in TypeScript since key names can't start with numbers in JavaScript unless they are surrounded with quotes. The fix would be to quote key names that start with numbers or other invalid characters (I'm pretty sure you can have JSON keys like "--foo"
, so maybe all keys that don't start with [A-z_]
should be quoted.
Set up versioning. Show version number on the website and clicking on that should open a changelog or redirect to a changelog in new tab.
It refreshes everytime a URL is changed and looks buggy.
Ideas or PR welcome.
This is a really cool project. I'm wondering what the prospects are for doing reverse transforms, or converting between e.g. PropTypes to typescript interfaces (which would enable automatic typing generation for React components that have PropTypes)
Is this something that this codebase could support or is it mainly geared towards 1-way transformations?
See #20 (comment)
If the the goal of converting JSON to typescript is to produce useful type/interfaces, then one should really choose my implementation
It supports more features that other libraries, has a simpler API, can merge multiple JSON blobs, and is more correct than any competition.
Please see the comparison table & tests for examples - if you have an interest in this, I'd be happy to send a PR
Thanks :)
Any chance to support Realm Scheme https://realm.io/docs/javascript/latest/#models
const Realm = require('realm');
const CarSchema = {
name: 'Car',
properties: {
make: 'string',
model: 'string',
miles: {type: 'int', default: 0},
}
};
const PersonSchema = {
name: 'Person',
properties: {
name: 'string',
birthday: 'date',
cars: {type: 'list', objectType: 'Car'},
picture: {type: 'data', optional: true}, // optional property
}
};
// Initialize a Realm with Car and Person models
Realm.open({schema: [CarSchema, PersonSchema]})
.then(realm => {
// ... use the realm instance to read and modify data
})
Thanks .
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
});
const Container = styled.View`
flex: 1;
background-color: white;
`
First, thanks for this awesome tool! it's been saving me a lot of time lately :D
so, i have some json that's not 100% valid
for example, i copied a js object, and i need to add quote marks around properties names
whenever i type something the cursor jumps to the end of the input
like this:
it's not that bad, i can always edit the source before pasting it. but it would be easier if i could just edit on the site, given that it already has a working JSON validator.
Thanks!
Instead of:
type Friends = {
id: number;
name: string;
}
can we have it generate:
type Friends = {
id: number,
name: string
}
(also, there should really be a semicolon after type __ = {}
for example:
<Test
className="some-class"
style={{ color: 'red' }}
onClick={() => this.doSomething()}
other
/>
becomes:
{
className: 'some-class',
style: { color: 'red' },
onClick: () => this.doSomething(),
other: true,
}
Since the recommended style for Rust is snake case, there should be an option to convert field names to snake case by using serde rename attribute.
Example:
#[derive(Serialize, Deserialize)]
struct RateLimits {
rateLimitType: String,
interval: String,
limit: i64,
}
#[derive(Serialize, Deserialize)]
struct RateLimits {
#[serde(rename = "rateLimitType")]
rate_limit_type: String,
interval: String,
limit: i64,
}
Needs some test that checks whether the json input is the default value or not before changing it
Hey @ritz078, awesome work here. I've been struggling with writing schemas for a couple of days recently and I know how it hurts 💯
I just wanted to add two other functionality to this excellent project here. I want to contribute to this as long as I can. This is the first one, if you wish I can do that.
Sometimes we copy js object instead of JSON:
{context:{type: "", content: "", page_index: -1})
I think we could JSON.stringify this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.