Create null value in dictionary to send to JSON

I am sending appointment information via JSON to an API using Xojo.Core.Dictionary. There is an integer field that, when it has a value represents an appointment and when null represents a break (in the schedule).

I can send the integer no problem using:

Dim appt As New Xojo.Core.Dictionary appt.value("patient") = patient_id //patient_id is an integer Dim json As Text =

but can’t figure out how to send a null value for the field.

appt.value("patient") = Nil //does not work appt.value("patient") = "null" //does not work

Any ideas would be greatly appreciated.

Your first try should do it. What does the JSON look like in that case?


But for some reason the API returns an error that a value is required.

However, in the documentation it states that the field can be either an integer or null.

In that posted JSON, the value is indeed null. Perhaps the API actually wants you to exclude it entirely?

When I omitted it entirely, I get this result:

{“patient”:[“This field is required.”]}

When I use the null value, I get this result:

{“patient”:[“This field may not be null.”]}

In the documentation, it states:

[code]patient integer or null required

ID of this appointment’s patient. Breaks have a null patient field.[/code]

I would have to guess that you can’t use the API to create a break in the schedule.

I concur, the documentation appears to be incorrect.