JSON Problem

edsicard

Member
Licensed User
Longtime User
Problem solved, DateTime format incorrect

When I try to convert a datetime to json format with JSONGenerator, no encoding is being done. What ever format I try the generator puts out same string I put in.


Code

Dim now As Long,dt As String,dm As Map
now = DateTime.now
dt = DateTime.Date(now) & " " & DateTime.Time(now)

Log("DT: " & dt)

' First Fill Map, all data needs to string type
dm.Initialize
dm.Put("ID","")
dm.Put("EmployeeID","1")
dm.Put("JobID","1")
dm.Put("TimeIn",dt)

' Second convert to Json
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize(dm)

Log("Json: " & JSONGenerator.ToString)
' Send it
PostJob.PostString(urlIn, JSONGenerator.ToPrettyString(2))
PostJob.GetRequest.SetContentType("application/json")
 
Last edited:
Top