Exception trying to retrieve array of objects

Previous .NET Client: 1.2.1
Updated .NET Client: 1.2.6
Server version: 2.0.0
Server OS: Windows

We have stored an array structure (IEnumerable), containing two FormFilter objects:

public void Save(string formTemplateId, List<FormFilter> formFilters)
        {
            _couchbaseRepository.InsertOrUpdate(formFilters, formTemplateId);
        }
[
  {
    "filterContext": {
      "filterType": "Wizard",
      "key": null,
      "name": "Wizard",
      "caseTypeCode": null,
      "productCode": null
    },
    "formFieldId": "SectionHoyreStolpe",
    "hidden": true,
    "disabled": false,
    "required": false
  },
  {
    "filterContext": {
      "filterType": "aaa_servicerequest",
      "key": null,
      "name": "Serviceoppdrag",
      "caseTypeCode": null,
      "productCode": null
    },
    "formFieldId": "SectionHoyreStolpe",
    "hidden": true,
    "disabled": false,
    "required": false
  }
]

When we "Get" the IEnumerable back from couchbase using:

//This should get a list of FormFilters from the key "FormFilterKey"
_couchbaseClient.GetJson<T>("FormFilterKey");

json.net throws an error because there is no id property on the top level object (a list):
Newtonsoft.Json.JsonSerializationException: Error converting value "id" to type 'Models.Filter.FormFilter'. Path '[0]', line 1, position 5. ---> System.ArgumentException: Could not cast or convert from System.String to Models.Filter.FormFilter.

Does the new client always need a top level object, so that we need to wrap the list in an object with an "id" property?

MyUnnecessaryProprtyListName: [
 {obj1},
 {obj2}
]

I think this is a bug.

0 Answers

No answers yet