Solved

processing JSON advanced

Posted on 2014-10-15
4
138 Views
Last Modified: 2014-10-16
I have the following JSON I was wondering how would you process it using JavaScript

I want to console.log teamname. SportsTypes

[
  {
    "teamname": "Bulldogs",
    "nickname": "",
    "SportTypes": {
      "-JZLOh7KtM78I5wAL6Ua": true
    },
    "locations": {
      "-JZLCFtpcuvsYxb5N1Cc": true
    }
  }
]

Open in new window

0
Comment
Question by:stargateatlantis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 43

Expert Comment

by:Rob
ID: 40383483
Assuming the code you've posted is in myobject:

Console.log(myobject[0].teamname);
Console.log(myobject[0].SportTypes);
0
 

Author Comment

by:stargateatlantis
ID: 40383569
So would I do this

Console.log(myobject[0].SportTypes['-JZLOh7KtM78I5wAL6Ua']);

Open in new window

0
 
LVL 43

Expert Comment

by:Rob
ID: 40383583
Yes, that is what you'd need to do to get that value.

You could also use the for/in loop to get the value too
0
 
LVL 43

Accepted Solution

by:
Rob earned 500 total points
ID: 40383588
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Debugging Html 8 32
Validating Date 4 29
Html split(text) Part2 6 23
close pop up windows when logout or main window closes 17 55
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question