0

I have difficulty to convert a long list to JSON string. This is my main model which I want to convert to JSON string

class ActivityBookingRequest {
  int adminId;
  List<ActivityBookingDetail> activityBookingList;

  Map toJson() {
    List<Map> activityBookingListMap = this.activityBookingList != null
        ? this.activityBookingList.map((i) => i.toJson()).toList()
        : null;
    return {
      'adminId': adminId,
      'activityBookList': activityBookingListMap,
    };
  }
}

This is my sub-model which is the list I am trying to serialize!

class ActivityBookingDetail {
  int bookingId;
  int resourceId;
  int sourceId;
  String sourceName;
  int productId;
  String pickupDate;
  String cutOffDate;
  int adultNumber;
  int childrenNumber;

  ActivityBookingDetail(
    this.bookingId,
    this.resourceId,
    this.sourceId,
    this.sourceName,
    this.productId,
    this.pickupDate,
    this.cutOffDate,
    this.adultNumber,
    this.childrenNumber,
  );

  Map<String, dynamic> toJson() {
    return {
      'ssId': bookingId,
      'ssResourceId': resourceId,
      'sourceId': sourceId,
      'sourceName': sourceName,
      'productId': productId,
      'pickupDate': pickupDate,
      'cutOffDate': cutOffDate,
      'noAdult': adultNumber,
      'noChild': childrenNumber,
    };
  }
}

When I convert this to a JSON string if the list is long, the final JSON string is getting cut off!

{"adminId":213,{"ssId":4,"ssResourceId":4,"sourceId":1,"sourceName":"TRES","productId":3,"pickupDate":"2022-09-08T18:30:00","cutOffDate":"2022-09-08T18:30:00","noAdult":1,"noChi
2
  • 1
    It is possible that it is being cut off by flutter when you are printing to console. Have you tried debugging the app and looking at what activityBookingList is in memory? Commented Sep 7, 2022 at 15:49
  • Might be related to stackoverflow.com/q/49138971/10122791 Commented Sep 7, 2022 at 18:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.