Pratik Butani
Pratik Butani

Reputation: 62419

Android JSONObject skipping null value while creating

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.

Upvotes: 1

Views: 222

Answers (2)

Pratik Butani
Pratik Butani

Reputation: 62419

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)));

Upvotes: 1

Ripityom
Ripityom

Reputation: 426

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

Upvotes: 0

Related Questions