Skip to content

Instantly share code, notes, and snippets.

@sandalsoft
Last active August 29, 2015 14:01
Show Gist options
  • Save sandalsoft/7e3cd7bae41aff6aef0a to your computer and use it in GitHub Desktop.
Save sandalsoft/7e3cd7bae41aff6aef0a to your computer and use it in GitHub Desktop.
Getting an error when I return json from my TickerSerializer serializer.
Error: Assertion Failed: You must include an `id` in a hash passed to `push`
This is becuase ember-data is looking for data.id from a serializer
(https://github.com/emberjs/data/blob/d9c47f10e3ee016f0bc0f0d5f4de1ebb294051c8/packages/ember-data/lib/system/store.js#L1205)
Is my JSON wrong?
TickerSerializer extends DS.JSONSerializer, and returns this JSON
(matches JSON conventions here: http://emberjs.com/guides/models/connecting-to-an-http-server/):
{
"ticker": {
"symbol": "AMZN",
"Ask": null,
"AverageDailyVolume": "4623070",
"Bid": "207.00",
"LastTradeDate": "5/23/2014",
"TradeDate": null,
"EarningsShare": "0.641",
"ErrorIndicationreturnedforsymbolchangedinvalid": null,
"EPSEstimateCurrentYear": "1.09",
"EPSEstimateNextYear": "3.31",
"EPSEstimateNextQuarter": "-0.05",
"DaysLow": "304.90",
"DaysHigh": "312.35",
"Name": "Amazon.com, Inc.",
"Notes": null,
"Open": "305.67",
"PreviousClose": "304.91",
"OneyrTargetPrice": "419.33",
"Volume": "3055997",
"HoldingsValue": null,
"HoldingsValueRealtime": null,
"YearRange": "258.34 - 408.06",
"DaysValueChange": "- - +2.40%",
"DaysValueChangeRealtime": "N/A - N/A",
"StockExchange": "NasdaqNM",
"DividendYield": null,
"PercentChange": "+2.40%",
"options": ["AMZN140530C00250000", "AMZN140530C00265000", "AMZN140530C00270000"],
"id": "AMZN"
},
"options": [{
"type": "C",
"strikePrice": "250",
"lastPrice": "55.00",
"change": "0",
"changeDir": null,
"bid": "60",
"ask": "64.45",
"vol": "1",
"openInt": "1",
"ticker": "AMZN",
"id": "AMZN140530C00250000"
}, {
"type": "C",
"strikePrice": "265",
"lastPrice": "26.95",
"change": "0",
"changeDir": null,
"bid": "45.7",
"ask": "48.75",
"vol": "6",
"openInt": "6",
"ticker": "AMZN",
"id": "AMZN140530C00265000"
}, {
"type": "C",
"strikePrice": "270",
"lastPrice": "33.00",
"change": "0",
"changeDir": null,
"bid": "40.75",
"ask": "43.6",
"vol": "3",
"openInt": "3",
"ticker": "AMZN",
"id": "AMZN140530C00270000"
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment