Dealing with nested JSON data

Does anyone know the best way to retrieve some relatively heavily nested JSON data when parsing/filtering in the course of a #fetch? I have a series of for loops and if statements in my filterFunction, but I think that is going to negatively affect performance....Are there other handy enyo or JS methods that could help me, or some aspect of the enyo framework that I am missing?

Comments

  • Can you share some more detail on what you're doing now and where you see problems? What filtering are you doing and could any of it be done server-side?
  • Oh I talked with some folks on the enyojs irc channel -- I think I've done about as much as I can do. Thanks anyways!
  • If you're able to control anything on the server, one strategy we've tried internally that works quite well is to have the api return a flattened representation of the tree. That is, we return arrays of records of various model types and import those into the store.

    To actually browse through the relational structure we then set up some getters on our model kinds to fetch the related records from the store. It works well and even allows us to observe and bind changes in nested models.

    There are quite a few changes to the data layer in 2.5.x, so I'm not sure if the approach we used still makes much sense within the current data-layer's implementation of relational data. I suspect you might not even need to add custom getters anymore now that relations are built into enyo's data layer itself.
Sign In or Register to comment.