2020-05-02

JSON all the things

I have a feeling that industry is moving away from XML and towards JSON...

Just a feeling, but even HMRC, who used to used XML for VAT and do for RTI, have moved to JSON for MTD (VAT).

Fundamentally XML is too complicated - especially with name spaces. The options in XSD (which is the common way to define what is valid in an XML file) is also a bit of a mess - defining the order of the XML objects even, which is a pain if you ever work with any XML. JSON does not expect values in an object to be in any order (just in an array).

JSON is simpler in many ways, but there are differences. The type of a simple value can be more than just text (as you have in XML), it can be null, boolean, number, or text. Javascript tents to just convert between things seamlessly in most cases. It does get to be fun in arrays where each value can be a different type, even an object or array itself.

JSON also makes it a lot easier to create and process using languages like Javascript, obviously.

As it happens, at A&A, we have been working on new APIs for our control systems (more on that another day), and these are all JSON based too. But this week I have started on some work on the accounts system.

I now have JSON for documents, i.e. invoices. We currently allow customers to access invoices in XML, PDF, Plain text, and HTML, and as of now also JSON. You can ask for a JSON attachment to be automatically included in your invoice emails if you wish - digitally signed, obviously.

Whilst we have loads of work behind the scenes improving the way the accounts work, this JSON interface should be pretty stable now.

4 comments:

  1. If you are making a few changes to the internal accounting systems may I suggest something? I wouldn't bother with all the allocating of payments to specific invoices. I would just do debits and credits. Legally a credit is allocated to the oldest debit, then the next oldest, etc. so any allocation that deviates from that is only superficial anyway.

    ReplyDelete
    Replies
    1. That is exactly what it does by default, allocates any payment to oldest date (by due date). If all things are paid within terms, in any order, that is always fine. But customers wanted to mess about, pay some invoices with specific payments and some other invoices late. Indeed, when we first added this feature, as someone asserted that they had paid specific invoices, we allocated as requested and it meant their late payment penalties actually increased as it changed which ones (and how many) were now late! But auto allocation in order remains the default.

      Delete
  2. Great work!
    How do you represent prices and monetary values? The implementations of numbers, especially non-Integers in JSON parsers is notoriously unreliable...

    ReplyDelete
    Replies
    1. Well, using decimals, with typically 2 decimal places. In our system we are using arbitrary precision decimal maths. We're not typically expecting the external systems using javascript, etc, to be doing much maths, e.g. ordering will present product codes and quantities and be told exact calculated totals back.

      Delete

Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.

Don't use UPS to ship to UK

I posted about shipping and importing and tax and duty - general info. But this is specific. DON'T USE UPS! I had assumed the UPS issue ...