Javascript query of JSON data file

Actually my original question was answered by Alexcode in a post named "XML query in Javascript"  I have a follow up question and didn't know if it could be viewed in the original post since it's closed.   As such the javascript that Alex presented is noted there.. Works wonderfully.   Please read it for the context of my follow up question..

I want to return multiple values of the query result.  If I query by "i" which is airport id I also want to return the "n" airport name and "t" and "g" the lat/long values.   I'm not sure how to do this.

Additionally, I want to move the JSON file to be external to the script.  How does this get named and also how do I reference the external JSON file from within the actual script doing the lookup

Thank you in advance for your input...
aviator21114Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aviator21114Author Commented:
Thank you for including the link for me.  I was in a hurry and didn't take the time to figure out how to do this... Apologies...
0
Eddie ShipmanAll-around developerCommented:
I use a library called JSONPath. It allows you to use XPath queries on your JSON data:

http://goessner.net/articles/JsonPath/

An example of how to find the airport data based on the ID would look something like the code in this fiddle:
http://jsfiddle.net/Mrbaseball34/5t9BD/


To move your JSON data into an external file just name it and include it in a script tag.
Assign your JSON data to a variable and it will be available in your unit if you add the link to the file before the link to your unit. i.e.
<script type="text/javascript" src="externalJSON.js"></script>
<script type="text/javascript" src="MyUnit.js"></script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eddie ShipmanAll-around developerCommented:
I update the fiddle to show how to have external data.
0
aviator21114Author Commented:
Eddie... Apologies, I didn't see that you had posted to my question...  Let me take a look at this and digest it..

Thank you,
0
Eddie ShipmanAll-around developerCommented:
Cleaning up after just a little over a month?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.