Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

How to find the asset id of a pageJSON specifics and escaping

Quotes and “ ” characters

Shared blocks

 

JSON structures

...

This is a bit confusing, so see Architecture>Interior Architecture for a good example of how it is used. (Asset id 309042)

The content element is used to provide extra information about the related degree where necessary. This is just a plain text field. See Economics and Finance>Actuarial Science for a good example of this (asset number 309568).

...

The commas are a particularly nasty issue, because nearly every json parser will allow there to be a comma after the last element without issue. The json interpreter within squiz though does not, and so some values that the angular app needs might be missing - such as the contentType and the region. Use the online validator here if you are unsure whether your commas are correct or not.

 

Debugging json objects

If you try to load a page and you get the following error:

Code Block
Sorry, something went wrong
JSON.parse

or looking at the topic api response:

Code Block
{"error": "JSON.parse",
"name": "SyntaxError",
...
}

or looking at the programme api response:

Code Block
{
   "sharedAssets": {
...
   },
   "errors": [
      {
      "message": "JSON.parse",
      "raw":
...
      }
   ]
}

Then there is an error with the json object somewhere.

Normally the easiest place to look is in the content of the last asset you were editing. Take that element out completely, try reloading the page and see if that helps. If it does, fix the element you removed and replace it.

Otherwise, it can be hard to discover. The "raw" value of the error will give you the raw contents of the asset, however it can be difficult turning that back into its original structure due to all the escaping involved.

There is currently another api endpoint for topics that will just return the unmodified, unchecked json object generated by squiz. It can be called like so:

http://cms.victoria.ac.nz/api/topicjsondebugger?q=TOPICNAME

If you copy and paste the contents of that page into a json validator, it can help to diagnose where the issue is for that topic.

If there's an issue with a programme, get Andrew Bredenkamp to build a programmejsondebugger api endpoint and then look at that when it's done.