Why when sending data over AJAX, do you have to JSON.stringify() your objects?

前端 未结 3 2083
栀梦
栀梦 2020-12-06 18:44

JSON stands for javascript object notation (as I\'m sure you\'re aware), so why, when sending json via ajax do you need to turn it into a string to send it? Is it simply a f

3条回答
  •  有刺的猬
    2020-12-06 19:06

    when sending json via ajax do you need to turn it into a string to send it?

    If it isn't a string, then it isn't JSON in the first place.

    JSON is a text based data format. HTTP is a text based communications protocol.

    JSON stands for javascript object notation

    JSON is based on the syntax for JavaScript literals. A JavaScript object is not JSON.

提交回复
热议问题