ember.js - Create / Update multiple objects from one API response -


All new jsfiddle:

Currently, I ask for an API Which return JSON like this For now the API can not be changed, which is why I have to work around it.

  [{"timestamp": 1406111961, "value": [1236.181, 1157.695, 698.231]}, {"timestamp": 1406111970, "value": [1273.455, 1153.577, 693.591]} ]  

(too many rows can be, at all)

As you can see, timestamps in each line and after that My problem is that there is an array of values, that I really want to move that. Looking at the first row alone: ​​

  {"timestamp": 1406111961, "value": [1236.181, 1157.695, 698.231]}  

Only some measurements taken in time will need to be created in my Amber Project:

  {"sensor_id": 1, // can be obtained from the array index "timestamp": 1406111961, "Value": 1236.181}, {"sensor_id": 2, "timestamp": 1406111961, "value": 1157.695}, {"sensor_id": 3, "timestamp": 1406111961, "value": 698.231}  

And those values ​​are related to sensors Must be pushed into the foundation.

The change itself is trivial, but I do not know how I will put it in Amber and how can I change many amber models.

You can make your model an array and override the normal method You can do normalize method on your adapter where you make changes, and since you have a Jason array, an amber Array will work as a model.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -