Discussion Forums  >  Config Data, JSON, App Refresh

Replies: 7    Views: 142

nobrainsleft (but still trying!)
Aspiring developer
Profile
Posts: 7
Reg: Oct 21, 2014
New York
2,320
11/25/14 05:05 PM (4 years ago)

Custom JSON file invalid

Hi, I'm trying to load a whole bunch of locations into a map in my app, but I don't want to add each one individually, so I created a JSON file to load them all at once. I formatted the script correctly as far as I can tell, and JSONlint says it is valid, but when my app tries to load the file it says there was an error in the JSON. I've compared the code to other working JSON files from other apps but still can't find my mistake! I'm copying the link to the file below, hopefully someone can figure it out!

https://www.buzztouch.com/applications063014/JA12B71DE7F5405C528834CCC/documents/JSON%20for%20wifi%20locator.txt

Thanks in advance!

P.S.- I'm very new to app making so this may have a very nooby mistake. :D
 
Niraj Shah
buzztouch Evangelist
Profile
Posts: 2937
Reg: Jul 11, 2012
Cerritos
37,870
like
11/25/14 08:04 PM (4 years ago)
Most likely the apostrophe is the problem.

Make a copy of your JSON file.

Then take it out of places such as Wolfe's Pond Park.

Try the new JSON file to see if the error goes away.

Then try to insert just one apostrophe, but precede it with a \ character. For example, Wolfe\'s Pond Park.

-- Niraj
 
Niraj Shah
buzztouch Evangelist
Profile
Posts: 2937
Reg: Jul 11, 2012
Cerritos
37,870
like
11/25/14 08:06 PM (4 years ago)
I cannot remember if the \ will let you escape out of that error while still keeping your apostrophe in the words.

I did some research and had a surprise -- I had previously answered this same question about apostrophes!


This was my advice back then:

If you need a single quote inside of a string, since \' is undefined by the spec, use \u0027 see http://www.utf8-chartable.de/ for all of them

So ... instead of the apostrophe or the single quote character, try to put \u0027 in it's place.

-- Niraj
 
Niraj Shah
buzztouch Evangelist
Profile
Posts: 2937
Reg: Jul 11, 2012
Cerritos
37,870
like
11/25/14 08:15 PM (4 years ago)
One more tip ...

After fixing the JSON file, remember to do a Clean and Run to start fresh.

You might also have to reset the Simulator to erase any cached JSON files.

-- Niraj
 
nobrainsleft (but ...
Aspiring developer
Profile
Posts: 7
Reg: Oct 21, 2014
New York
2,320
like
11/26/14 04:42 AM (4 years ago)
OK, I'll try that! Thanks so much!
 
nobrainsleft (but ...
Aspiring developer
Profile
Posts: 7
Reg: Oct 21, 2014
New York
2,320
like
11/26/14 05:03 AM (4 years ago)
Could I use a curly apostrophe in places like "Wolfe’s Pond Park"? I know from troubleshooting my code earlier that those are not recognized to close the line.
 
feraco
Aspiring developer
Profile
Posts: 704
Reg: Jan 23, 2012
nyc
15,040
like
11/26/14 05:23 AM (4 years ago)
I would change it to "Wolfes Pond Park"
 
nobrainsleft (but ...
Aspiring developer
Profile
Posts: 7
Reg: Oct 21, 2014
New York
2,320
like
11/26/14 10:43 AM (4 years ago)
OK, will do. Thanks!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.