OK… this project isn’t as easy as it was yesterday…. So in the process of creating the contacts page I found a bug in the JSON output for my view. It really wasn’t easy to find either…
I started as I normally do by creating the basic page template and JS code that I have done for the past two pages. I ran into a problem when my getJSON call wasn’t returning any results (the success callback wasn’t being called). I took the URL and pasted into a browser and every looked fine. The server was the same, so no cross domain issues. No errors on the server console. ACL was the same as the other database…. what was going on!
Reading though the doc on JQuery.getJSON I found this note:
Important: As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently. Avoid frequent hand-editing of JSON data for this reason. JSON is a data-interchange format with syntax rules that are stricter than those of JavaScript’s object literal notation. For example, all strings represented in JSON, whether they are properties or values, must be enclosed in double-quotes. For details on the JSON format, see http://json.org/.
Hmmm….. could this be my problem? I went back to the output I got from the browser window and pasted it into a JSON validator and sure enough there was a problem.
Parse error on line 77: ... "0": "Teamstudio CIAO\! C -----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
So it looks as if Domino is trying to escape a the ‘!’ character when it shouldn’t be. This won’t fly with the JSON.parse call that JQuery.getJSON uses.
CRAP!
I have to say, I seem to run into this way too often with Notes and Domino. There are so many useful features that are just not robust enough to use. Even worse is most of the bugs you find are not easily worked around and you never seem to find them until you are a week into a project. It is extremely frustrating!
I have a few alternatives that I can explore so unless anyone has any ideas how to fix this, I think I’m gonna ditch the views and switch to an agent. I think that even though the agent is more work, there are a lot of cool possibilities that it offers that wouldn’t have been possible with just a view. Though, I really did like the simplicity and ease of reuse the views offered…. they just don’t do what they advertise.