Question

I want to send JSONObject from mobile to server in Android. There are some null values which also i want to send.

I have tried following both way but its SKIPPING NULL values.

tempJsonValuesOrder.put(DatabaseHelper.ORDER_OTHERS, orderCursor.isNull(orderCursor.getColumnIndex(DatabaseHelper.ORDER_OTHERS)) ? null :orderCursor.getString(orderCursor.getColumnIndex(DatabaseHelper.ORDER_OTHERS)));

Is there any way to put null value in JSONObject?

Help will be appreciated.

Was it helpful?

Solution

After all i found solution like:

tempJsonValuesOrder.put(DatabaseHelper.ORDER_TRANSPORT, orderCursor.isNull(orderCursor.getColumnIndex(DatabaseHelper.ORDER_TRANSPORT)) ? "" :orderCursor.getString(orderCursor.getColumnIndex(DatabaseHelper.ORDER_TRANSPORT)));

OTHER TIPS

You could try setting those values to empty Strings, if it is suitable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top