How to import only a part of json file in react?

I use a json file as a config file. In a react component, I do not need all parameters.
For example,
myjson.json file

{
  "part1": {
    "param1": 12,
    "param2": "aaa"
  },
  "part2": {
    "param1": 47,
    "param2": "bbb"
  }
}

In my xxx.js file, with the code import myjson from './myjson.json'; , I get the whole json file in the myjson object.
How can I directly import only part1 of the json file?
Thanks for answer.

16 thoughts on “How to import only a part of json file in react?”

Leave a Comment