Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am working with jSON, an API and AngularJS. I want to get the following data, but I will not know in advanced what the keywords or the dates will be

{
"landscape gardening middlesex": {
    "2015-02-12": {
        "position": null,
        "change": "n/a",
        "class": "gray"
    },
    "2015-03-17": {
        "position": "0",
        "change": "n/a",
        "class": "gray"
    }
},
"landscape gardening staines": {
    "2015-02-12": {
        "position": null,
        "change": "n/a",
        "class": "gray"
    },
    "2015-03-17": {
        "position": "94",
        "change": "n/a",
        "class": "green"
    }
},
"landscape gardening surrey": {
    "2015-02-12": {
        "position": null,
        "change": "n/a",
        "class": "green"
    },
    "2015-03-17": {
        "position": "0",
        "change": "n/a",
        "class": "gray"
    }
}

} How can i retrieve this using AngularJS ng-repeat Thanks.

share|improve this question
    
That's not JSON... –  Jonathan yesterday
1  
This question does not make sense. Please rewrite it. –  brianvaughn yesterday
    
Can you store the 'date' objects in an array instead? Otherwise you can just loop through the properties on the parent object and operate on them. –  dustmouse yesterday
    
And what @brianvaughn said... –  Jonathan yesterday
    
Yeah sorry not very clear. By retrieve, I mean cycle through them pretty much like what @dustmouse said and then put them in to the Angular template. I have seen the ng-repeat, but i'm very new to Angular and API's. –  devon93 yesterday

1 Answer 1

create a javascript object and store it somewhere... you can always stringify it then re-parse it

var myJSON = {
  name: "bill",
  skills : ["coding", "sleeping", "eating"],
  age : 25 
};

// this string can be stored anywhere,  like even as a string in mySQL.
var string = JSON.stringify( myJSON );  


///  Turn Back into JSON obj
var newJSON = JSON.parse(string);
console.log( newJSON.name );    //  >>  "bill"

/// Hope this helps

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.