Discussion Forums  >  Config Data, JSON, App Refresh

Replies: 5    Views: 116

Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
03/04/13 01:00 PM (11 years ago)

JSON validator invalid?

Hi folks, This has been driving me nuts for days! I'm working with the JSON Snippet keeper building an app. Simple scenario - 20 menus drive 20 screens of 4 options. Generally I have it working except I'm trying to get the main menu to work. I have this JSON (below) that works fine in the app/snippet, but when I post it into the validator it fails. If I correct it (usually quotes around "childitems") then it fails in the app. Is the validator valid :) Here's the json... -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8< {"itemId":"S2", "itemType":"BT_screen_menuButtons", "itemNickname":"SayIt", "navBarTitleText":"SayIt", "buttonLayoutStyle":"grid", "buttonLabelLayoutStyle":"below", "buttonLabelFontColor":"#FF0000", "buttonSizeSmallDevice":"120", "buttonPaddingSmallDevice":"25", "buttonCornerRadiusSmallDevice":"5", "buttonLabelFontSizeSmallDevice":"17", "buttonSizeLargeDevice":"120", "buttonPaddingLargeDevice":"25", "buttonCornerRadiusLargeDevice":"5", "buttonLabelFontSizeLargeDevice":"20", "childItems":[{"itemId":"SFB2", "itemType":"BT_buttonItem", "loadScreenWithItemId":"Facebook2", "titleText":"Facebook It", "imageNameSmallDevice":"Facebook_icon.png", "transitionType":"fade", "imageNameLargeDevice":"Facebook_icon.png"}, {"itemId":"STWIT2", "itemType":"BT_buttonItem", "loadScreenWithItemId":"TWIT2", "titleText":"Tweet It", "imageNameSmallDevice":"twitter_icon.jpg", "transitionType":"fade", "imageNameLargeDevice":"twitter_icon.jpg"}, {"itemId":"SSMS2", "itemType":"BT_buttonItem", "loadScreenWithItemId":"SMS2", "titleText":"Text It", "imageNameSmallDevice":"SMS_Icon.jpg", "imageNameLargeDevice":"SMS_Icon.jpg"}, {"itemId":"SEmail2", "itemType":"BT_buttonItem", "loadScreenWithItemId":"EMAIL2", "titleText":"Share by Mail", "imageNameSmallDevice":"Email_Icon.jpg", "imageNameLargeDevice":"Email_Icon.jpg"}]} -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8< As an additional item, if I put a comma on the end, and another item it fails too. (Works in the app/snippet) Thoughts? Thanks.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/04/13 01:33 PM (11 years ago)
Oddly enough, when I run it through Jsonlint, it comes out as valid data. I once spent several days until I discovered that although my json data would 'validate' with json lint, I had included several "invisible" characters such as linefeeds, tabs, and other things that would NOT let my data work, but it would pass validation. Drove me nuts. Good Luck! Cheers! -- Smug
 
Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
like
03/04/13 02:09 PM (11 years ago)
Well I got it all working, but the problem above still stands true. I did learn another important lesson, the BT JSON window (or maybe JSON itself) only seems to allow 1000 lines of JSON Since my created JSON is >2000 lines, it had to be broken into 3 snippets. (131,331 characters). Once I split it into 3 parts it worked just fine. Phew, that was a tricky one.
 
Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
like
03/04/13 07:36 PM (11 years ago)
OK, it looks like I didn't post all the JSON... I'll try again... {"itemId":"S1", "itemType":"BT_screen_menuButtons","itemNickname":"S1","navBarTitleText":"No","buttonLayoutStyle":"grid","buttonLabelLayoutStyle":"below","buttonLabelFontColor":"#FF0000","buttonSizeSmallDevice":"120","buttonPaddingSmallDevice":"25", "buttonCornerRadiusSmallDevice":"5","buttonLabelFontSizeSmallDevice":"17","buttonSizeLargeDevice":"120","buttonPaddingLargeDevice":"25","buttonCornerRadiusLargeDevice":"5","buttonLabelFontSizeLargeDevice":"20", "childItems":[{"itemId":"SFacebook1", "itemType":"BT_buttonItem", "loadScreenWithItemId":"Facebook1", "titleText":"Facebook It", "imageNameSmallDevice":"Facebook_icon.png", "transitionType":"fade", "imageNameLargeDevice":"Facebook_icon.png"},{"itemId":"STWIT1","itemType":"BT_buttonItem", "loadScreenWithItemId":"TWIT1", "titleText":"Tweet It", "imageNameSmallDevice":"twitter_icon.jpg", "transitionType":"fade", "imageNameLargeDevice":"twitter_icon.jpg"},{"itemId":"SSMS1","itemType":"BT_buttonItem", "loadScreenWithItemId":"SMS1", "titleText":"Text It", "imageNameSmallDevice":"SMS_Icon.jpg", "imageNameLargeDevice":"SMS_Icon.jpg"},{"itemId":"SMail1", "itemType":"BT_buttonItem", "loadScreenWithItemId":"EMAIL1", "titleText":"Share by Mail", "imageNameSmallDevice":"Email_Icon.jpg", "imageNameLargeDevice":"Email_Icon.jpg"}]}, {"itemId":"S2", "itemType":"BT_screen_menuButtons","itemNickname":"S2","navBarTitleText":"No","buttonLayoutStyle":"grid","buttonLabelLayoutStyle":"below","buttonLabelFontColor":"#FF0000","buttonSizeSmallDevice":"120","buttonPaddingSmallDevice":"25", "buttonCornerRadiusSmallDevice":"5","buttonLabelFontSizeSmallDevice":"17","buttonSizeLargeDevice":"120","buttonPaddingLargeDevice":"25","buttonCornerRadiusLargeDevice":"5","buttonLabelFontSizeLargeDevice":"20", "childItems":[{"itemId":"SFacebook2", "itemType":"BT_buttonItem", "loadScreenWithItemId":"Facebook2", "titleText":"Facebook It", "imageNameSmallDevice":"Facebook_icon.png", "transitionType":"fade", "imageNameLargeDevice":"Facebook_icon.png"},{"itemId":"STWIT2","itemType":"BT_buttonItem", "loadScreenWithItemId":"TWIT2", "titleText":"Tweet It", "imageNameSmallDevice":"twitter_icon.jpg", "transitionType":"fade", "imageNameLargeDevice":"twitter_icon.jpg"},{"itemId":"SSMS2","itemType":"BT_buttonItem", "loadScreenWithItemId":"SMS2", "titleText":"Text It", "imageNameSmallDevice":"SMS_Icon.jpg", "imageNameLargeDevice":"SMS_Icon.jpg"},{"itemId":"SMail2", "itemType":"BT_buttonItem", "loadScreenWithItemId":"EMAIL2", "titleText":"Share by Mail", "imageNameSmallDevice":"Email_Icon.jpg", "imageNameLargeDevice":"Email_Icon.jpg"}]} The computer says Yes, but the validator says No
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/04/13 10:39 PM (11 years ago)
Well, on the above json, you have two valid json objects, but they're not 'grouped' correctly. So, you have two valid menus (menu buttons) in an invalid configuration. Cheers! -- Smug
 
Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
like
03/05/13 06:06 AM (11 years ago)
They are supposed to be two seperate menus, any idea how to 'group' them correctly so the JSON can be validated :) While working with many screens I try to check each element to ensure the JSON was formed correctly, picking the whole projects JSON does show as valid, but that's a bit of a pain to do in the validator. Thx
 

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.