javascript says JSON object property is undefined although it's not

后端 未结 4 583
抹茶落季
抹茶落季 2021-01-18 00:02

I have a json-object, which I print to the screen (using alert()-function):

alert(object);

Here is the result:

Then I want

4条回答
  •  遥遥无期
    2021-01-18 00:55

    Looks like your json object is not really an object, it's a json string. in order to use it as an object you will need to use a deserialization function like JSON.parse(obj). Many frameworks have their own implementation to how to deserialize a JSON string.
    When you try to do alert(obj) with a real object the result would be [object Object] or something like that

提交回复
热议问题