Questions tagged [mongo-jackson-mapper]

42 questions
20
votes
5 answers

Efficient POJO mapping to/from Java Mongo DBObject using Jackson

Although similar to Convert DBObject to a POJO using MongoDB Java Driver my question is different in that I am specifically interested in using Jackson for mapping. I have an object which I want to convert to a Mongo DBObject instance. I want to use…
mark
  • 59,016
  • 79
  • 296
  • 580
10
votes
1 answer

Jackson ObjectMapper ignore all properties that has no annotation

My target is is to convert jsonObject to Class. I want to add only fields that are anotated in Class. Example: json object holds 50 fields. Class has 4 fields. I want to map only exact 4 fields without adding 46 addition ignores in class. JSON: { …
IntoTheDeep
  • 4,027
  • 15
  • 39
  • 84
9
votes
6 answers

Jackson JSON Deserialization of MongoDB ObjectId

Ok, so first off here's the JSON that's returning from my web service. I'm trying to deserialize it into pojos after an asynchronous query in a ResponseHandler in my Android ContentProvider. {"exampleList" : [{ "locationId" : "00001" , "owners" : […
Matt M
  • 185
  • 1
  • 1
  • 8
8
votes
1 answer

@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) not working

While serialization of the class DataType the dbOptions is been ignored but dataType is being printed with its value. Note I need to ignore the these property only during serialization and not deserialization. @JsonTypeInfo(use =…
souravlahoti
  • 716
  • 2
  • 8
  • 29
8
votes
2 answers

Serialize one class in two different ways with Jackson

In one of our projects we use a java webapp talking to a MongoDB instance. In the database, we use DBRefs to keep track of some object relations. We (de)serialize with POJO objects using jackson (using mongodb-jackson-mapper). However, we use the…
Gijs
  • 5,201
  • 1
  • 27
  • 42
7
votes
2 answers

Jackson - Wrapping a list of objects with root object

My Controller returns a list of MyObj objects (using @ResponseBody) public MyObj { int a; int b; } The return JSON looks like this: [{"a":1,"b":2},{"a":2,"b":2}] I would like to wrap this JSON so it will return something like: { "data":…
6
votes
2 answers

How can I deserialize a nested wrapped String in Jackson?

I have a JSON string that contains a nested and wrapped JSON string. I'd like to deserialize this using Jackson but I'm unsure how. Here's a sample bean: @JsonIgnoreProperties(ignoreUnknown = true) public class SomePerson { public final String…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
4
votes
1 answer

Using Jackson XML Mapper to get a list

I currently am working with Jackson to read an XML file from an online location, map it to an object and then insert that object into MongoDB using the Object Mapper. At the moment my dataset looks something like this:
ist_lion
  • 3,149
  • 9
  • 43
  • 73
2
votes
1 answer

constructor Arguments and Spring Data De-Serialization Issue

Using Spring Data with MongoDB. Problem is in instantiating a bean retrieved from Mongo because the constructor has some argument which actually is inside a nested object. Persistance is not an issue. Retrieval Is. Class structure is as below where…
DragonZoned
  • 201
  • 3
  • 14
2
votes
1 answer

Deserializing Properties class using Jackson fasterxml

I am trying to use Jackson with fasterxml (vs codehaus) to get some data I store in mongoDb deserialized. The query is returning the proper json string, but I keep getting this error what we try to convert it to an object: Can not deserialize…
Wael Awada
  • 1,506
  • 3
  • 18
  • 31
2
votes
2 answers

How to use Jackson ObjectMapper to parse json response to java objects

Here is my Json response "postedevent": [ { "status": "true", "event_id": "800", "num_of_image_event": "0", "title": "Testy", "photo":…
HemangNirmal
  • 621
  • 1
  • 8
  • 24
2
votes
1 answer

compare two collections in mongodb using java or an simple query

I am having following document (Json) of an gallery, { "_id": "53698b6092x3875407fefe7c", "status": "active", "colors": [ "red", "green" ], "paintings": [ { …
2
votes
0 answers

mongojack: Unrecognized field at subclass

I use mongojack to map my POJOs for mongoDB. It works fine with a Single POJO. But if I make a Subclass of this an insert fails: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "created" (class…
youseeus
  • 347
  • 7
  • 24
2
votes
2 answers

unmarshall aggregate result with Jongo

I am using the MongoDB aggregate framework to query a document, the results is the following: { "result" : [ { "_id" : "luke", "times" : 8 }, { …
nuvio
  • 2,555
  • 4
  • 32
  • 58
1
vote
0 answers

Phantom dot in keys of map loaded from mongodb

I have an entity with the following fields: var name: String?, var metadata: org.bson.Document?, var things: Map = mapOf(), var other_things: Map = mapOf(), @Indexed(unique = true) var hash: String? The keys of…
1
2 3