Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad format JSON #1

Open
smidaharoun opened this issue Mar 30, 2016 · 2 comments
Open

Bad format JSON #1

smidaharoun opened this issue Mar 30, 2016 · 2 comments

Comments

@smidaharoun
Copy link

It should be JSONArray instead of JSONObject.
It making it harder to deal with

@ram-nadella
Copy link
Owner

@smidaharoun the JSON is structured that way to allow the case of a single code lookup in the dictionary rather than having to iterate over the entire list.

Which language are you working in? Is there a way to get the values from the JSONObject? Or may be get the keys as a list and then iterate over the keys and get the values that way?

If you can't find a solution, applying the patch below will change the code to generate a JSON with an array of airport data objects. Run ruby reformat.rb at the root of the repo to get the generated airports.json file.

diff --git a/reformat.rb b/reformat.rb
index 708ada9..f5911a9 100644
--- a/reformat.rb
+++ b/reformat.rb
@@ -1,10 +1,10 @@
 require "csv"
 require "json"

-airport_data = {}
+airport_data = []

 CSV.foreach("airports.dat") do |row|
-  airport_data[row[4]] = {
+  airport_data << {
     :name => row[1],
     :city => row[2],
     :country => row[3],

@ptrkstr
Copy link

ptrkstr commented Jan 21, 2022

This should be closed as it's not an issue. It is valid json and is in a format that improves look up speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants