JSON is not steamed, what is the reason?
-
good afternoon, trying to get objects from JSON but it doesn't work, what is the reason?
function setJson(responseJson) { console.log(responseJson) var message = JSON.parse(responseJson) for (var i = 0; i < 2; i++) { if (message.type == "send") { load_dataSend(message.textm) } else { load_dataGet(message.textm) } } }
And here is the JSON itself:
[{"id": 1, "id_user": 2, "text": "Hello everyone!", "date": "Nov 6, 2020", "type": "send", "status": "read" }, {"id": 2, "id_user": 2, "text": "Goodbye everyone!", "date": "Nov 6, 2020", "type": "get", "status": "new "}]JavaScript Anonymous, Oct 13, 2020 -
It turns out it automatically parses, you can like this responseJson [i] .textAnonymous
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!