Created
September 11, 2015 07:43
-
-
Save ryanlabouve/f952f7cfe4b33b5b482f to your computer and use it in GitHub Desktop.
Camelize Json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName:'Ember Twiddle', | |
| payload: { | |
| key_one: "Here is the first value", | |
| key_two: "Here is the second value!" | |
| }, | |
| originalPayload: Ember.computed('', function() { | |
| return JSON.stringify(this.get('payload')); | |
| }), | |
| camelizeJson: Ember.computed('', function() { | |
| let payload = this.get('payload'); | |
| let keys = Ember.keys(payload); | |
| let newObj = {}; | |
| keys.forEach(function(key) { | |
| Ember.set( | |
| newObj, | |
| Ember.String.camelize(key), | |
| payload[key] | |
| ); | |
| }); | |
| return JSON.stringify(newObj); | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.4.10", | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember.debug.js", | |
| "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js", | |
| "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment