Note that there are some explanatory texts on larger screens.

plurals
  1. POmapping JSON to an Object
    primarykey
    data
    text
    <p>I have a JSON file that was converted from a csv and is too big to hand edit. Its' syntax is one large array I think. The data is from a group of routers and I aim to build router objects. The way the current CSV to JSON file is organized by each row and I want to pick out each router and have an object with router name, the all bandwidth measurements associated with that router.</p> <p>How would you approach this? I'm attempting to take care of all of this when I iterate through the JSON file and when the router changes, I start a new instance of the router object. I'm a no longer a newb, just a slow learner. So would the next step be to create a router class with js and populate the class with what I pull out of my giant JSON array, or could/should I do with out the handwritten class and create all the objects on the fly? (can I create objects on the fly.</p> <p>Current JSON (it goes on for pages, each router having a few hundred entries in the csv:</p> <pre><code>[ { "Router": "RouterID1", "TimeStamp": "2012/01/01 06:00:00", "transferBytes": "23235", "ReceivedBytes": "29903" }, { "Router": "RouterID1", "TimeStamp": "2012/01/01 06:05:00", "transferBytes": "21235", "ReceivedBytes": "22103" } { "Router": "RouterID2", "TimeStamp": "2012/01/01 06:00:00", "transferBytes": "23235", "ReceivedBytes": "29903" }, { "Router": "RouterID2", "TimeStamp": "2012/01/01 06:05:00", "transferBytes": "21235", "ReceivedBytes": "22103" } ] </code></pre> <p>@amnotiam: the router types are gauranteed to be adjecent to each other</p> <p>This might not be valid but here is the structure I think I'm going for:</p> <pre><code>[ { "Router": "RouterID1" "TimeStamp": array of timestamps "transferBytes": array of bytes transferred for each timestamp "ReceivedBytes": array of bytes received for each timestamp }, { "Router": "RouterID2", "TimeStamp": array of timestamps "transferBytes": array of bytes transferred for each timestamp "ReceivedBytes": array of bytes received for each timestamp } ] </code></pre> <p>@Bergi I want to make an object for each router with there historical data contained with in the object. Right know I have an object for every time entry. (I think)</p> <p>@Rick Good call, I will be and will probably ask that question later:)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload