0

This is the format of my JSON file. I am fairly new to javascript and want to be able to read each key and pull each augment. I am just confused on where to start.

AuthServer.Web": {
    "stuff": {
        "evenmore stuff": {
            "evermore": "3d91f44c-2453-489c-bb61-dd42df803179",
            "anything": "6cc7b9d0-423c-471a-be77-7c95d432e50d",
            "things": "https://auth-drip.coree.com",
            "environment": "dev",
            "migrate": "1"
},
1
  • 2
    It is not a valid json Commented Sep 23, 2016 at 14:12

1 Answer 1

1

https://jsonformatter.curiousconcept.com/

This site is a json validator. You can plug your JSON string in and it will tell you if it is valid, and if not what is wrong.

In javascript you can use var myData = JSON.parse(yourData) to get your JSON into an object. After that depending on how you build your JSON you can loop through it using the variable names you assign.

Just to get a rough idea based on what I think you were trying to do, you can do something like this.

for(var x=0; x<myData.stuff.length; x++){
    for(var y=0; y<myData.stuff[x].length; y++){
        for(var z=0; z<myData.stuff[x].evenmoreStuff[y].length; z++){
            alert(myData.stuff[x].evenmoreStuff[y].anything.toString()
        }
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

I didnt put the full json file because it is huge (over 800 lines) but it is indeed valid. I

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.