A
A
Alexey Mairin2018-04-08 12:00:08
JavaScript
Alexey Mairin, 2018-04-08 12:00:08

How to get information from a Json file that is stored locally?

Hello!
Help me please! I have a data.json file
like

[
      {
            "id": 1,
            "valueName": "Австралийский доллар",
            "name": "AUD",
            "oneCount": "1",
            "currentCourse": "1,5091"
      },

and a few more fields
1) Have I formed the JSON file correctly? by canon?
2) How can I display this data in html / save it in some kind of array in js

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Zotov, 2018-04-08
@modelair

var file = require('./data.json')

D
Daniil Lebedinsky, 2018-04-08
@Lebed71

You have incorrectly formed JSON.
Try something like this:

{
    "array": [
        {
         "foo": "bar"
        }
    ]
}

after that, connect it, as you were suggested to do above and work with the array field (of course, you can call it whatever you like)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question