JSON Syntax

There are some basic Syntax mistakes to avoid when creating JSON files, whilst most of these will be rejected by the Shipping API should you mistakenly send them, they’ve been listed below in order to help should you get an error response returned for a message.

  • Always enclose the key and value pair within double quotes. Most JSON systems do not like to parse JSON objects with single quotes
  • Never use underscores in your key fields. The shipping API uses Camel case. This is the practice of writing key phrases without spaces or punctuation. The separation of words is indicated by the capitalisation of the first letter of a word. (e.g HaveCupOfTea).
  • Use a JSON linter to confirm that the JSON you’re creating is valid. There are many such tools readily available on the internet, which can be used to prove that the structure and syntax of your JSON message is correct (Note: They are not able to prove the content of your message is correct, you can do this via the Royal Mail test environment).