Convert a custom object to JSON in Totalcross

1

You can serialize a Custom Object to JSON without having to enter field-to-field, such as:

JSONObject jsonObject = new JSONObject();                       
jsonObject.put("id", meuObjeto.id);
jsonObject.put("dt_sync", meuObjeto.dtSync);
jsonObject.put("dt_modif", meuObjeto.dtModif);

I tried to pass the object by parameter in the JSONObject constructor

JSONObject jsonPedido = new JSONObject(pedido);

But some values are lost.

In Java, Android etc ... you can use the JACKSON lib for example to generate an Object Map and convert it to a JSON ... Or via annotations .. anyway ..

Is there a more agile way of implementing this Custom Object serialization for a JSONObject in Totalcross?

    
asked by anonymous 05.10.2017 / 20:55

0 answers