so I'm building an app and I'm reading a JSON file so I can add a new reservation but after searching online I didn't find any way to add a new dict to a list using visual basic and Newtonsoft.JSON.
The json file:
{"reservations": [{"time": "07:00 pm", "tableId": "1", "clientName": "Antonio Goncalves", "status": "pending"}]}
Basically I want to add a new dictionary of values inside the reservations list.
The current function
Public Sub SetReservation(time As String, tableId As String, clientName As String, Optional status As String = "pending")
Dim reservationFile As String = File.ReadAllText(reservationJsonFile)
If Not String.IsNullOrEmpty(reservationFile) And Not String.IsNullOrWhiteSpace(reservationFile) Then
Dim reservationJson = Linq.JObject.Parse(reservationFile)
Dim newReservationObject = Linq.JObject.FromObject(New Dictionary(Of Object, Object) From {{"time", time}, {"tableId", tableId}, {"clientName", clientName}, {"status", status}})
Trace.WriteLine(newReservationObject)
End If
End Sub
List(Of Reservation). Then you can simply add a newreservationto the list, serialize it and save to file.