hiranthaR / Json-to-Dart-Model

Json to Dart Model extension can convert JSON objects into Dart data classes. It supports pure Dart class conversion, Flutter-recommended JSON serialization using annotations, Freezed support, Effective Dart:Style, and many more features. Currently, it has more than 135,000 installs.
https://marketplace.visualstudio.com/items?itemName=hirantha.json-to-dart
MIT License
93 stars 18 forks source link

Fix nested array not generating properly #14

Closed apgapg closed 3 years ago

apgapg commented 3 years ago
{
  "NoSalesReasons": [
    {
      "MainReason": "PRODUCT RELATED ISSUE",
      "ChildStatement": "Which out of following best describes the reason for product related issue ?",
      "ChildReasonChoices": [
        "Product Complaint",
        "Low Shelf Offtake",
        "Expiry Issue"
      ]
    }
  ]
}

Nested Array such as in ChildReasonChoices are not generated properly. Instead of List<String> data type of ChildReasonChoices, List<ChildReasonChoices> data type is generated, causing errors.

This PR attempts to fix nested array by commenting out a line in helper.ts.
l.push(v); causes incorrect data type of the element inserted which makes array [ String, String,String, [String, String,String ] ]thereby making mergeableListType function to return incorrect data type (ie of the last element inserted which is array)