JSON.stringify returns “[object Object]” instead of the contents of the object

前端 未结 4 966
梦如初夏
梦如初夏 2020-12-30 19:28

Here I\'m creating a JavaScript object and converting it to a JSON string, but JSON.stringify returns \"[object Object]\" in this case, instead of

4条回答
  •  没有蜡笔的小新
    2020-12-30 19:52

    theObject.toString()
    

    The .toString() method is culprit. Remove it; and the fiddle shall work: http://jsfiddle.net/XX2sB/1/

提交回复
热议问题