XML and JSON — Advantages and Disadvantages?

前端 未结 8 724
遥遥无期
遥遥无期 2020-12-22 22:12

I recently heard about JavaScript Object Notation (JSON), and after looking it up, it seems like it\'s becoming rather popular as an alternative to the Extensible Markup Lan

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-22 22:32

    XML

    • Can have a schema that states its format.
      • This is of interest to quality control people. You can prove that its format matches what is expected, and therefore you may not have to be quite as fervent as you might otherwise be at checking that a field exists within it every time you want to reference one.
      • (Though this pre-supposes that you go out of your way to actually validate the XML against its schema.)
    • Bloated; each field name has to be written out twice per field. Ew!

    JSON

    • Far less bloated, easier to parse and arguably more human readable (if you space it out properly).
    • Not quite as powerful: not expressive enough to separate attributes from values.

提交回复
热议问题