Please Help with Json

I’m having trouble using a json on the following model, I would like to know if it is possible to use it on this model.I apologize for english, i’m using google translator.

{
"oc_category": {
"columns": [
"category_id",
"image",
"parent_id",
"top",
"column",
"sort_order",
"status",
"date_added",
"date_modified"
],
"records": [
[
25,
"",
0,
1,
1,
3,
1,
"2009-01-31 01:04:25",
"2020-06-04 12:01:34"
],
[
20,
"catalog/demo/compaq_presario.jpg",
0,
1,
1,
1,
1,
"2009-01-05 21:49:43",
"2020-06-04 12:04:51"
],
[
24,
"",
0,
1,
1,
5,
1,
"2009-01-20 02:36:26",
"2020-06-04 11:59:21"
]
]
}
}

Hello, in order to let someone understand your problem and try to help, you should provide more context informations. What is your goal? What do you want to do with that Json object?

@patrick_dm

so this json comes from an open API, what I need is to use this information from him to configure an application to show the products. but this structure is very strange, it was not possible to understand how it would be possible

Indeed a strange response for a json api, anyway it is defenitly possible to reach the records array and parse it into instances of a custom class. You will have to decode the response json, at root level, getting to the columns and the records arrays, you may then get rid of the columns and map onto the records array to produce a list of records objects that you may then list in your application.

Here is a possible solution, tested in DartPad:

import 'dart:convert';

class MyRecord {
  const MyRecord({
    this.categoryId,
    this.image,
    this.parentId,
    this.top,
    this.column,
    this.sortOrder,
    this.status,
    this.dateAdded,
    this.dateModified,
  });

  final categoryId;
  final image;
  final parentId;
  final top;
  final column;
  final sortOrder;
  final status;
  final dateAdded;
  final dateModified;

  factory MyRecord.parse(json) {
    return MyRecord(
      categoryId: json[0],
      image:  json[1],
      parentId: json[2],
      top: json[3],
      column: json[4],
      sortOrder: json[5],
      status: json[6],
      dateAdded: json[7],
      dateModified: json[8]
    );
  }

}

void main() {
  List<MyRecord> recordsList;
  
  final String respObj = '''{
    "oc_category": {
      "columns": [
        "category_id",
        "image",
        "parent_id",
        "top",
        "column",
        "sort_order",
        "status",
        "date_added",
        "date_modified"
      ],
      "records": [
        [
          25,
          "",
          0,
          1,
          1,
          3,
          1,
          "2009-01-31 01:04:25",
          "2020-06-04 12:01:34"
        ],
        [
          20,
          "catalog/demo/compaq_presario.jpg",
          0,
          1,
          1,
          1,
          1,
          "2009-01-05 21:49:43",
          "2020-06-04 12:04:51"
        ],
        [
          24,
          "",
          0,
          1,
          1,
          5,
          1,
          "2009-01-20 02:36:26",
          "2020-06-04 11:59:21"
        ]
      ]
    }
  }''';

  final response = json.decode(respObj);
  final ocCategory = response['oc_category'];
  final records = ocCategory['records'] as List;
  
  recordsList = records.map((r) => MyRecord.parse(r)).toList();
  
  print("Records in recordsList: " + recordsList.length.toString());
  
  print("First record category_id: "+  recordsList[0].categoryId.toString());
  print("First record date_added: "+  recordsList[0].dateAdded);
  
  print("Second record category_id: "+  recordsList[1].categoryId.toString());
  print("Second record image: "+  recordsList[1].image);
}

Records in recordsList: 3
First record category_id: 25
First record date_added: 2009-01-31 01:04:25
Second record category_id: 20
Second record image: catalog/demo/compaq_presario.jpg