How does JSON compare to XML in terms of file size and serialisation/deserialisation time?

前端 未结 8 1818
萌比男神i
萌比男神i 2020-12-28 16:43

I have an application that performs a little slow over the internet due to bandwidth reasons. I have enabled GZip which has improved download time by a significant amout, bu

8条回答
  •  無奈伤痛
    2020-12-28 16:48

    actually this is harder to answer then it seems,

    several years ago json was 'faster' but the differences have become finer between the two.

    what I've observed is;

    • xml compresses better with gzip then json .. time saved in download can offset other components
    • xml parsing/querying in raw js is roughly equiv with json
    • xml parsing/querying in jquery is much slower ... I won't begrudge jquery developers to focus on json

    overall, tech that speeds up modern browsers also applies to xml processing as well.

    generally, whenever I hear json touted as a 'lowfat' alternative to XML I wonder if its not some subliminal obsession with weight issues ... thats on my pessimistic days;

    basically the rule of thumb I follow is

    markup good for documents json good for data

    and move on ... nothing to see here

提交回复
热议问题