Squeez
Squeez

Reputation: 959

Spring MVC MongoDB Index

Now my backend send to UI ObjectID as an object with timestamp, machineIdentifier, etc., but in database it stores as hex representation. Is there any way (annotation or something else) to serialize it to json as hex representation?

Upvotes: 0

Views: 41

Answers (2)

Andrea Girardi
Andrea Girardi

Reputation: 4437

I solved in this way:

JSONObject idObj = (JSONObject)obj.get("_id");
String strID = (String) idObj.get("$oid");

Upvotes: 1

Squeez
Squeez

Reputation: 959

Helped changing id type from ObjectId to String.

Upvotes: 0

Related Questions