M
M
Mr1is2018-11-09 01:54:57
JavaScript
Mr1is, 2018-11-09 01:54:57

How to get value from json to console?

This json comes from the server localhost:8888/get_serial.json and you need to get this value from it - 123456789012 to the console

{
  "document": {
    "data": {
      "docType": 1,
      "name": "С",
      "fiscprops": [
        {
          "caption": "З",
          "printable": "З\t123456789012",
          "tag": 1013,
          "value": "123456789012"
        }
      ]
    },
    "result": 0
  },
  "protocol": 1,
  "version": "1.0"
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sokhin, 2018-11-09
@roamn

Hello.

// Парсим в объект
const json = JSON.parse('{"document": {"data": {"docType": 1, "name": "С", "fiscprops": [{"caption": "З", "printable": "123456789012", "tag": 1013, "value": "123456789012"} ] }, "result": 0 }, "protocol": 1, "version": "1.0"}');

// Выводим нужное значение
console.log(json.document.data.fiscprops[0].value);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question