0

Let's say I have class:

Public Class License
    Public Property orderID As Int64? = 0
    Public Property productID As Int64? = 0
    Public Property licenseKey As String = 0
End Class

Which I use to successfully serialise to json with:

Dim userLicense As New License With {.LicenseKey = "D780F-CD87E"}
Dim json as String = JsonConvert.SerializeObject(UserLicense)

This correctly produces the json:

{
  "orderID": 0,
  "productID": 0,
  "licenseKey": "D780F-CD87E",
}

I use this class a lot throughout the app to interface with an API. However, one of the API POST functions requires the field names to be different for each of the properties. An example of the required format is:

{
  "order_number": 0,
  "product_URN": 0,
  "license_Key": "D780F-CD87E",
}

This does still map directly onto the License class. I don't want to have to construct a whole new class for this one API request method. Is there any way to provide the serialiser with a 'map' of alternative key names? I've looked through the documentation but couldn't see how this could be done.

Thanks for any help offered.

Guru Stron
  • 42,843
  • 5
  • 48
  • 70
stigzler
  • 582
  • 1
  • 7
  • 25

0 Answers0