Need to serialize a property that can come as a single object or an object array

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hi there.

      I faced and exception today and don't quite know how to work around it. Couldn't find anything similar online aswell.

      So, I consume a webservice, and it returns me an xml that I convert to a json and later on save it to a Mongo database. I'm saving it as BsonDocument, once I don't know every property on the json to map a working C# model (I can't ensure that the property will always be the same).
      Later on the code, I retrive that information to a previously maped model class and I add the "BsonIgnoreExtraElements" annotation to it. Inside that class, I've got a List<> property, but in my json the equivalent of that property, it's a single object, not an array.

      Is there anyway that I force that value to always be serialized as an array? Even if on the mongo database it was saved as a single.

      Thanks !

            Assignee:
            Wan Bachtiar
            Reporter:
            Rafael Gianine
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: