Generate ember data models from JSON


#1

Hi all, I wanted to speed up my ember development so I created a little tool that generates ember data code from json you paste in the online editor. I hope it helps someone.

Demo:

http://quantuminformation.github.io/Javascript-code-generation-tools/

Give it this:

{
  "shouldBeNumber1": "1",
  "shouldBeString1": ".1",
  "shouldBeBoolean1": "false",
  "shouldBeFragment1": {
    "FshouldBeNumber1": "1",
    "FshouldBeString1": "bar",
    "FshouldBeBoolean1": "false"
  }
}

Get this back (copy paste it into files):

Ember data

  import DS from 'ember-data';

export default DS.Model.extend({
  shouldBeNumber1: DS.attr("number"),  
  shouldBeString1: DS.attr("string"),   
  shouldBeBoolean1: DS.attr("boolean"),  
  shouldBeFragment1: DS.hasOneFragment("shouldBeFragment1")  
});

export default DS.ModelFragment.extend({
  FshouldBeNumber1: DS.attr("number"),  
  FshouldBeString1: DS.attr("string"),   
  FshouldBeBoolean1: DS.attr("boolean")  
});