ProWorks Blog

A Problem With JSON

By Wesley Kos     Wednesday, July 25, 2012     development, web, websites, umbraco, json
 15 16 ShareThis

A few weeks back Savages and Scoundrels Timeline broke. The timeline which was usually filled with wonderful tidbits of hitorical knowledge had vanished from the page. I ventured off into the XSLT to find the solution to this problem. 

It did not take long after examining the XSLT to decide that the problem was not there. My next thought was the JSON which we fetch our data from. I grabbed the JSON object which was used to display our object and checked it with a JSON Viewer. Invallid JSON object. 

After a careful examination of the JSON Object I found that it was formatted correctly. All of the brackets matched, square and squiggly. The strings had values and quotes, and the values had quotes and trailing commas. It was a correctly formatted JSON object. The question was why was the JSON viewer telling me it was an invalid JSON object.

The answer came from Jason Prothero. He had run into something like this before and informed me of the problem.

The Umbraco content which we were pulling our data from had HTML inside the content itself. The HTML spaces which were used for indenting the text caused the JSON to be incorrectly formatted. 

The solution of stripping out the HTML before trying to use the JSON object fixed the problem which left us with a very historical website. 

The take away from this I think should be "No matter how great something looks, watch out for HTML because it hates you!".

Best,

  Wesley

 15 16 ShareThis
comments powered by Disqus
comments powered by Disqus

1 memorable comment for "A Problem With JSON"


  1. Posted 9/10/2012 3:43:37 AM

    Thanks for the URL. i have faced some problem with json when i was developing a application but somehow i managed. But this url will help me a lot.