Selecting a portion of a JSON array and applying variables in javascript or jquery

Posted by user1644609 on Stack Overflow See other posts from Stack Overflow or by user1644609
Published on 2012-10-28T03:17:09Z Indexed on 2012/10/28 5:01 UTC
Read the original article Hit count: 131

Filed under:
|
|

I am retrieving a JSON file that returns its results like what you see below. The JSON has 365 days worth of data. I would like to create "views" of this JSON using javascript, one which pulls the last 10 days, then 1 month, 6 months, etc.

After the getJSON function I am doing this to get a string as JSON, then turn it into an object and will then graph it. So I would like each "view" to be an object for the specified timeframe (using the one JSON). The obj_10days, obj_1month, etc variables would then be plotted.

var $ graph = data ;
var obj = $ . parseJSON ( $ graph ) ;

JSON:

[

    {
        "Low": 8.63,
        "Volume": 14211900,
        "Date": "2012-10-26",
        "High": 8.79,
        "Close": 8.65,
        "Adj Close": 8.65,
        "Open": 8.7
    },
    {
        "Low": 8.65,
        "Volume": 12167500,
        "Date": "2012-10-25",
        "High": 8.81,
        "Close": 8.73,
        "Adj Close": 8.73,
        "Open": 8.76
    },
    {
        "Low": 8.68,
        "Volume": 20239700,
        "Date": "2012-10-24",
        "High": 8.92,
        "Close": 8.7,
        "Adj Close": 8.7,
        "Open": 8.85
    },

Any help is appreciated, thank you!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery