Remove Map/Empty/List Node from vert.x JsonObject serialized String

298 views
Skip to first unread message

Xin WANG

unread,
Jul 31, 2020, 12:14:55 AM7/31/20
to vert.x

The structure of the Object I want to serialize is

```java
public class MongoDatasourceResponse { private Mongoresponse response; private List<JsonObject> data; private int size; private Error error; //get, set method... }
```

Vert.x JsonObject Serialized String contains "Map" and "empty" filed, But I do not want to have all these extra "map" and "empty" nodes. What I can I do to remove them?

```json
{ "code": -1, "data": [ { "map": { "n": 0, "writeErrors": { "list": [ { "map": { "index": 0, "code": 11000, "errmsg": "E11000 duplicate key error collection: test.users index: _id_ dup key: { : 5 }" }, "empty": false }, { "map": { "index": 1, "code": 11000, "errmsg": "E11000 duplicate key error collection: test.users index: _id_ dup key: { : 6 }" }, "empty": false }, { "map": { "index": 2, "code": 11000, "errmsg": "E11000 duplicate key error collection: test.users index: _id_ dup key: { : 3 }" }, "empty": false }, { "map": { "index": 3, "code": 11000, "errmsg": "E11000 duplicate key error collection: test.users index: _id_ dup key: { : 7 }" }, "empty": false } ],"empty": false }, "ok": 1.0 }, "empty": false } ], "size": 0, "error": null }

```

zeRf7.png

Julien Viet

unread,
Jul 31, 2020, 2:06:27 AM7/31/20
to vert.x
Hi,

you do need to parse the string and remove them from there.

If you don't want to recreate an in memory structure you could try using the event driven parser and emit a new json string without the parts you don't want

Julien

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/91a07fb6-3a6c-42c8-968a-7a29827fd787n%40googlegroups.com.

Xin WANG

unread,
Jul 31, 2020, 2:32:21 AM7/31/20
to vert.x
Thanks for your reply, I have registered a MessageCodec for ArrayList in my program but it does not help, is there any easy/simple solution I can do to remove the extra node in serialized string of JsonObject?

Xin WANG

unread,
Aug 5, 2020, 11:44:17 PM8/5/20
to vert.x
Is any one have any idea?
Reply all
Reply to author
Forward
0 new messages