Problem with jsonItem creation

Hello Everyone,

I am trying to create a JsonItem from an object. I create a new JsonItem named as json which is {}.
I loop my object and i add values to my jsonItem. e.g.
{“Modified”:0,“esft2_active”:1}

After some loops my jsonItem lose every data and become empty without the brackets.
Does anyone has an issue on this?

Thank you very much!

It sounds like, at some point, you can assigning a new JSONItem to the variable that holds your main JSONItem, but we’d have to see your code.

dim ti as Introspection.TypeInfo = Introspection.GetType(o)
Dim s As String
for each prop as Introspection.PropertyInfo in ti.GetProperties
json.Value(prop.Name) = prop.Value(o)
next

Here is my code.

Does anyone has a clue? :confused:

I found out that when I assign a Currency value to a jsonItem.Value then the problem occurs.
If I Format the Currency like

json.Value(“price”) = Format(rs.Fiel(“price”).CurrencyValue,"-0.00")

then jsonItem is created all correct.

Does anyone knows if this is a bug?

Json itself doesn’t support “currency” natively. Only numbers, strings, booleans, nulls and other json objects. Now you may say that currency is a number, but json has no idea about what precision to use. Better to be explicit and convert it to/from one of the valid types yourself.

Thank you Greg for your answer.

I didn’t know that. I expected jsonItem to be able to handled that.
I have already changed currency to Double and Date to String and everything works ok.

[quote=347287:@Sebastian Kapellas]Thank you Greg for your answer.

I didn’t know that. I expected jsonItem to be able to handled that.
I have already changed currency to Double and Date to String and everything works ok.[/quote]
http://json.org