Mapping JSON into Class Objects

后端 未结 5 912
你的背包
你的背包 2020-12-19 05:15

I am trying to map my JSON file into a class object, and then update the cards based on the newly received JSON.

My JSON structure is like this

 {
          


        
5条回答
  •  情深已故
    2020-12-19 05:43

    I created some useful library for this using reflection called json_parser which is available at pub.

    https://github.com/gi097/json_parser

    You can add the following to your dependencies.yaml:

    dependencies:
      json_parser: 0.1.1
      build_runner: 0.8.3
    

    Then the json can be parsed using:

    DataClass instance = JsonParser.parseJson(json);
    

    Follow the README.md for more instructions.

提交回复
热议问题