Opened 9 years ago

Closed 9 years ago

#10624 closed defect (invalid)

ItemFileReadStore fails on certain simple JSON.

Reported by: Eugene Lazutkin Owned by: Jared Jurkiewicz
Priority: high Milestone: tbd
Component: Data Version: 1.4.0
Keywords: Cc:
Blocked By: Blocking:

Description

Helping a user with his problem (http://stackoverflow.com/questions/1977170/display-custom-label-from-data-store-with-dojox-charting) I found that ItemFileReadStore fails with errors while opening seemingly simple JSON.

For example this JSON fails:

{
  "identifier": "id",
  "items": [
    {"id": 1, "slice": {"y":55,"text":"Free"}},
    {"id": 2, "slice": {"y":45,"text":"Used"}}
  ]
}

I don't know if it violates something but the error thrown is "arrayOfItems is undefined", which is at the very least misleading and doesn't give any clues to what the actual problem is.

This JSON works without problems.

{
  "items": [
    {"id": 1, "slice": {"y":55,"text":"Free"}},
    {"id": 2, "slice": {"y":45,"text":"Used"}}
  ]
}

Attachments (2)

wchart.html (1.0 KB) - added by Eugene Lazutkin 9 years ago.
wchart.json (110 bytes) - added by Eugene Lazutkin 9 years ago.
"good" json

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by Eugene Lazutkin

Attachment: wchart.html added

Changed 9 years ago by Eugene Lazutkin

Attachment: wchart.json added

"good" json

comment:1 Changed 9 years ago by Eugene Lazutkin

While I use charting to demonstrate a problem, the charting itself is not needed. The exception is thrown when "parsing" the JSON file before charting starts in play.

comment:2 Changed 9 years ago by Jared Jurkiewicz

Resolution: invalid
Status: newclosed

This violates ItemFileReadStore? rules regarding IDs:

http://docs.dojocampus.org/quickstart/data/usingdatastores/faq#question-10-in-one-of-my-items-in-itemfilereadstore-i-defined-an-attribute-value-as-a-javascript-object-but-i-didn-t-set-an-identifier-the-store-blows-up-with-an-error-about-no-identifier-when-fetching-why-does-it-care

You specify an identifier in failing example, but you assign no ids to child items, so they have no identifer. This fails item parsing because all items (including nested objects (which are considered items) must have an identifier defined.

You can also avoid this in 1.4 by specifying herarchical: false on the datastore before it loads data and it will not treat nested objects as items.

Note: See TracTickets for help on using tickets.