Create a JSON Object Containing a Named Array of Strings

Julio Bello 221 Reputation points
2021-03-24T08:20:23.57+00:00

Hi, Everybody! Please see my class below...

    [DataContract]
    public class PutShipmentsReleaseRequest : BaseRequest
    {
        [DataMember(Name = "ShipmentIds")]
        public string[] ShipmentIds { get; set; } // Mandatory, The tracking number or Unique Id of the shipment to defer
    }

When it is serialized, it looks like this...

["3A02939620000008A1977","3A02939620000008A198D","3A02939620000008A199B","3A02939620000008A19A9"]

I need it to look like this...

{ "ShipmentIds": ["3A02939620000008A1977","3A02939620000008A198D","3A02939620000008A199B","3A02939620000008A19A9"] }

How can I achieve the desired output?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,306 questions
{count} votes