When to prefer JSON over XML?

Favor XML over JSON when any of these is true:

  • You need message validation
  • You’re using XSLT
  • Your messages include a lot of marked-up text
  • You need to interoperate with environments that don’t support JSON

Favor JSON over XML when all of these are true:

  • Messages don’t need to be validated, or validating their deserialization is simple
  • You’re not transforming messages, or transforming their deserialization is simple
  • Your messages are mostly data, not marked-up text
  • The messaging endpoints have good JSON tools

Leave a Comment