Struggling to save JSON array in Flutter

Hello, I have the following JSON in my database (entered through the browser console). It works perfectly with my code and I’m happy with the shape of the data:

{
  "features": [
    {
      "title": "stairs",
      "description": "beep bop boop"
    },
    {
      "title": "lift",
      "description": "beep bop boop"
    }
  ],
  "venueAccessibilityUrl": "https://www.tate.org"
}

I then have the following class:

@reflector
class VenueAccessibility {
  List? features;
  String? venueAccessibilityUrl;
  String? title;
  String? description;
}

Which is being called inside the Venue class like this:

class Venue {
  late VenueAccessibility? accessibilityInfo;

I run into trouble when trying to save a new venue to the db. This is how I want to do it:

VenueAccessibility tateBritainAccessibilityInfo = VenueAccessibility()
    ..features = [
      {
        "title": "title1",
        "description": "desc1"
      },
     {
        "title": "title2",
        "description": "desc2"
      }
    ]
    ..venueAccessibilityUrl =
        "https://www.tate.org#accessibility";

However the array features is not showing up at all, the object has only the venueAccessibilityUrl. I don’t know what I’m doing wrong! Please help!

Hello, @Ilayda_B.

One simple question to clarify: is this problem only for Android?

Regards, Nikita.

Hi Nikita,

Yes, I haven’t got the project up and running on iOS yet, so have only been using an android emulator.

I talked to the team about this. We do not support creating objects in a table with the json type using classes. If you want to achieve this behavior parse your class into a map(or just use maps instead of classes for this query.) and submit a request.

However, this is supported in the new version of flutter-sdk (creating an object that contains a json column). At the moment, the version in early access 8.0.0-alpha.6 is already available: backendless_sdk 8.0.0-alpha.6 | Flutter Package.

There are quite a few breaking changes, so your application may require a bit of refactoring.

Best Regards, Nikita.

1 Like

Thanks for the information, I’ll attempt to save an object using just Maps for now as I don’t want to deal with breaking change - good to know it’s being supported in upcoming versions! :+1:t4:

Also, speaking of the Flutter SDK, I have another quick question. I get the following error when trying to run the app on iOS:

[!] CocoaPods could not find compatible versions for pod "BackendlessSwift":
      In snapshot (Podfile.lock):
        BackendlessSwift (= 6.5.1)
      In Podfile:
        backendless_sdk (from `.symlinks/plugins/backendless_sdk/ios`) was resolved to 0.0.1, which depends on
          BackendlessSwift (= 6.7.8)
    Specs satisfying the `BackendlessSwift (= 6.5.1), BackendlessSwift (= 6.7.8)` dependency were found, but they required a higher minimum deployment target.

Which is the correct version number?

Can you try to call this commands:

cd ios
pod repo update
pod install
cd ..

Thank you for you your help, these commands

cd ios
pod repo update

these commands prompted me to also run pod install --repo-update and sudo gem install cocoapods with pod update BackendlessSwift.

Sorted now, thanks for the help! :pray:t4: