Discussion Forums  >  Config Data, JSON, App Refresh

Replies: 13    Views: 357

Becky
I hate code!
Profile
Posts: 269
Reg: Aug 08, 2012
NYC
6,140
09/08/14 08:35 PM (10 years ago)

Invalid Json

I have some invalid Json but I don't know what the validator is trying to tell me. Please see screenshot... https://www.dropbox.com/s/kuysi2sq7p14mr3/Screen%20Shot%202014-09-08%20at%208.23.28%20PM.png?dl=0
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/08/14 08:42 PM (10 years ago)
Does your app tell you it's invalid? It's clear you're using the Ultimate Screen Creator (or Ultimate Droid Creator), as the standard JSON is replaced with my own custom markup. However, it should still validate to JSON. The problem is, I can't see the rest of the data in your screenshot. If the app reads it fine, then I wouldn't worry about it.
 
Becky
I hate code!
Profile
Posts: 269
Reg: Aug 08, 2012
NYC
6,140
like
09/08/14 08:46 PM (10 years ago)
That's the problem - the apps not reading it. Can I pm you the Json to look it over?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/08/14 08:48 PM (10 years ago)
sure
 
Becky
I hate code!
Profile
Posts: 269
Reg: Aug 08, 2012
NYC
6,140
like
09/08/14 08:53 PM (10 years ago)
Thanks, Chris. It's sent.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/09/14 05:33 AM (10 years ago)
Thanks - here's my reply I sent you on pm, as it may help someone else: Thanks Becky. Looks like the issue is in the screen "********* ********". You have a lot in that screen, and I'm wondering if the database has a limit on the amount of text one screen can have for it's JSON configuration. Try simplifying that screen a bit if you can. If I get some time I'll poke around the database structure on my self-hosted server to see if there's a limit we need to be worried about.
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
09/09/14 11:07 AM (10 years ago)
If that truly is your Line 1, and the first character of your JSON is a " ... All of my BT config.txt files start with a { ... {"BT_appConfig": And that is what your Validator was telling you: Your first character is a " and it was looking for a { or [. It said Expecting { or [, and it even put a caret ^ showing where it was expecting a { or [. I'm not sure that I use JSON in any other contexts than my config.txt. So if this JSON is anything other than config.txt, you need to be aware of the punctuation needs of that (type of) file. BUT, it might be looking for a { or [ as the first character of the first line, because maybe the last character of the last line is a } or ]. Whatever, JSON needs to be balanced. Balanced sets of [ and ] and { and } and ( and ). If you open the door, you close the door. Don't leave the door open when you quit, and don't try to close a door that was never opened.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/09/14 11:55 AM (10 years ago)
Nick - that was just a snippet of a much larger config file that you saw in her link.
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
09/09/14 12:32 PM (10 years ago)
The screen cap said "Line 1". How can you process a "snippet" in a JSON Validator, when the primary purpose of a JSON Validator is to count the {[( and )]}?... Without making sure the "snippet" starts and ends in balance?... Is the "snippet" bad, or just the open/close balance?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/09/14 12:39 PM (10 years ago)
She tried validating the entire config, but only showed a small screenshot of the error message. The face that it says "line 1" is because it failed to recognize the entire thing as JSON so couldn't identify the exact line number where the problem occurred. (I know because I saw the entire file). The issue was with a screen created using the Ultimate Screen Creator where some of the JSON got cut off. I believe the issue is due to the fact that the JSON for a particular screen gets saved in the database in a column of type "text". This type of column has an upper limit of data of 64kb. It would probably be better to have this column type be "mediumtext" instead, given the large amount of data going through that screen.
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
09/09/14 12:50 PM (10 years ago)
Yes, I've dealt with that in mySQL before. Text and Blobs! http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html Scroll down to Storage Requirements for String Types That's another reason why I don't - or try not to - do SQL data tables anymore. I save data as text files: data1.txt, data2.txt, and read them back in. I use my Arrays, and with the PHP 'serialize' command to save, and 'unserialize' to read back in. I'm so tired of the constraints of SQL.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/09/14 12:53 PM (10 years ago)
Has it's advantages and disadvantages. Saving as txt files on the server can certainly be less overhead, although you have to worry about security a little more. Would be pretty tough to take that approach on a Buzztouch plugin, though, since you can't use php in the control panel pages. If I could, I would've gone a completely different route.
 
Becky
I hate code!
Profile
Posts: 269
Reg: Aug 08, 2012
NYC
6,140
like
09/13/14 10:28 PM (10 years ago)
Hey Chris - I managed to cut the content of the screen in half. Everything was fine until I tried to add the iPad content and now I'm getting the invalid Json message again. I'm fine with not doing iPad for now ( I just want to get the app up) but now it seems it screwed my Json up again. Any thoughts? Update: I checked the Json and it said it was valid so I copied it to the config file. Everything is good except I'm going to back off the iPad and maybe do an update in the future. ---Thanks for all your help!
 
Nicks App
Code is Art
Profile
Posts: 426
Reg: May 21, 2014
Las Vegas
6,010
like
09/14/14 10:11 PM (10 years ago)
The iPad content - does that test Valid in the JSON Validator by itself? If so, or if not, it still may come down to the right balance of {[( and )]}, and the use of commas, when you paste in the JSON code. {[( and )]}, before and after.
 

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.