Search Results

Search found 232 results on 10 pages for 'jackson'.

Page 1/10 | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • Jackson object mapping - map incoming JSON field to protected property in base class

    - by Pete
    We use Jersey/Jackson for our REST application. Incoming JSON strings get mapped to the @Entity objects in the backend by Jackson to be persisted. The problem arises from the base class that we use for all entities. It has a protected id property, which we want to exchange via REST as well so that when we send an object that has dependencies, hibernate will automatically fetch these dependencies by their ids. Howevery, Jackson does not access the setter, even if we override it in the subclass to be public. We also tried using @JsonSetter but to no avail. Probably Jackson just looks at the base class and sees ID is not accessible so it skips setting it... @MappedSuperclass public abstract class AbstractPersistable<PK extends Serializable> implements Persistable<PK> { @Id @GeneratedValue(strategy = GenerationType.AUTO) private PK id; public PK getId() { return id; } protected void setId(final PK id) { this.id = id; } Subclasses: public class A extends AbstractPersistable<Long> { private String name; } public class B extends AbstractPersistable<Long> { private A a; private int value; // getter, setter // make base class setter accessible @Override @JsonSetter("id") public void setId(Long id) { super.setId(id); } } Now if there are some As in our database and we want to create a new B via the REST resource: @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Transactional public Response create(B b) { if (b.getA().getId() == null) cry(); } with a JSON String like this {"a":{"id":"1","name":"foo"},"value":"123"}. The incoming B will have the A reference but without an ID. Is there any way to tell Jackson to either ignore the base class setter or tell it to use the subclass setter instead? I've just found out about @JsonTypeInfo but I'm not sure this is what I need or how to use it. Thanks for any help!

    Read the article

  • Jackson + Builder Pattern?

    - by Gili
    I'd like Jackson to deserialize a class with the following constructor: public Clinic(String name, Address address) Deserializing the first argument is easy. The problem is that Address is defined as: public class Address { private Address(Map<LocationType, String> components) ... public static Builder { public Builder setCity(String value); public Builder setCountry(String value); public Address create(); } } and is constructed like this: new Address.Builder().setCity("foo").setCountry("bar").create(); Is there a way to get key-value pairs from Jackson in order to construct the Address myself? Alternatively, is there a way to get Jackson to use the Builder class itself?

    Read the article

  • Jackson XML globally set element name for container types

    - by maxenglander
    I'm using Jackson 1.9.2 with the XML databind module. I need to tweak the way that Jackson serializes arrays, lists, collections. By default, with an int array property called myProperty containing a couple numbers, Jackson / XML is producing the following: <myProperty> <myProperty>1</myProperty> <myProperty>2</myProperty> </myProperty> What I need to produce is: <myProperty> <item>1</item> <item>2</item> </myProperty> I can do this on a per-POJO basis using a combination of JacksonXmlElementWrapper and JacksonXmlProperty like so: @JacksonXmlElementWrapper(localname='myProperty') @JacksonXmlProperty(localname='item') public int[] myProperty; This solution, however, would require that I manually apply these annotations to every array, list, collection in my POJOs. A much better solution would allow me to apply a solution once, globally, for all array, list, collection types. Any ideas on how to implement such a solution? Thanks!

    Read the article

  • JSON Formatting with Jersey, Jackson, & json.org/java Parser using Curl Command

    - by socal_javaguy
    Using Java 6, Tomcat 7, Jersey 1.15, Jackson 2.0.6 (from FasterXml maven repo), & www.json.org parser, I am trying to pretty print the JSON String so it will look indented by the curl -X GET command line. I created a simple web service which has the following architecture: My POJOs (model classes): Family.java import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class Family { private String father; private String mother; private List<Children> children; // Getter & Setters } Children.java import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class Children { private String name; private String age; private String gender; // Getters & Setters } Using a Utility Class, I decided to hard code the POJOs as follows: public class FamilyUtil { public static Family getFamily() { Family family = new Family(); family.setFather("Joe"); family.setMother("Jennifer"); Children child = new Children(); child.setName("Jimmy"); child.setAge("12"); child.setGender("male"); List<Children> children = new ArrayList<Children>(); children.add(child); family.setChildren(children); return family; } } My web service: import java.io.IOException; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jettison.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; import com.myapp.controller.myappController; import com.myapp.resource.output.HostingSegmentOutput; import com.myapp.util.FamilyUtil; @Path("") public class MyWebService { @GET @Produces(MediaType.APPLICATION_JSON) public static String getFamily() throws IOException, JsonGenerationException, JsonMappingException, JSONException, org.json.JSONException { ObjectMapper mapper = new ObjectMapper(); String uglyJsonString = mapper.writeValueAsString(FamilyUtil.getFamily()); System.out.println(uglyJsonString); JSONTokener tokener = new JSONTokener(uglyJsonString); JSONObject finalResult = new JSONObject(tokener); return finalResult.toString(4); } } When I run this using: curl -X GET http://localhost:8080/mywebservice I get this in my Eclipse's console: {"father":"Joe","mother":"Jennifer","children":[{"name":"Jimmy","age":"12","gender":"male"}]} But from the curl command on the command line (this response is more important): "{\n \"mother\": \"Jennifer\",\n \"children\": [{\n \"age\": \"12\",\n \"name\": \"Jimmy\",\n \"gender\": \"male\"\n }],\n \"father\": \"Joe\"\n}" This is adding newline escape sequences and placing double quotes (but not indenting like it should it does have 4 spaces after the new line but its all in one line). Would appreciate it if someone could point me in the right direction.

    Read the article

  • Android compatibility with Restlet/JSON/Jackson

    - by Cookie
    Hi there, I'm currently working on a webservice-client for Android. I'm using a Java client library which provides an abstraction for interaction with the service. The client library works on normal machines. However, when I use the classes in my Android project, some calls don't return a result on Android, the background-service stops working at the first of those commands. Wireshark shows a tcp exchange, the server gets the requests. There is no exceptions or anything. Something in the serialization/deserialization semms not to work. I'm using the newest version of Jackson libraries (1.5.3) and the restlet jar in the android edition. Is there any known problems with Jackson and Android? Which code and libraries are compatible with Android? Thanks in advance.

    Read the article

  • Jackson Vs. Gson

    - by Null Pointer
    After searching through some existing libraries for JSON, I have finally ended up with these two: Jackson Google GSon I am a bit partial towards GSON, but word on the net is that GSon suffers from certain celestial performance issue. I am continuing my comparison, in the meanwhile I was looking for help to make up my mind.

    Read the article

  • How to convert a JSON string to a Map<String, String> with Jackson JSON

    - by Infinity
    This is my first time trying to do something useful with Java.. I'm trying to do something like this but it doesn't work: Map<String, String> propertyMap = new HashMap<String, String>(); propertyMap = JacksonUtils.fromJSON(properties, Map.class); But the IDE says: 'Unchecked assignment Map to Map<String,String>' What's the right way to do this? I'm only using Jackson because that's what is already available in the project, is there a native Java way of converting to/from JSON? In PHP I would simply json_decode($str) and I'd get back an array. I need basically the same thing here. Thanks!

    Read the article

  • Jackson - suppressing serialization(write) of properties dynamically

    - by kapil.israni
    I am trying to convert java object to JSON object in Tomcat/jersey using Jackson. And want to suppress serialization(write) of certain properties dynamically. I can use JsonIgnore, but I want to make the ignore decision at runtime. Any ideas?? So as an example below, I want to suppress "id" field when i serialize the User object to JSON.. new ObjectMapper.writeValueAsString(user); class User { private String id = null; private String firstName = null; private String lastName = null; //getters //setters }//end class

    Read the article

  • Restlet/Jackson works differently when object implements Serializable

    - by ravyoli
    I am sending an object with some primitive fields using Restlet with Jackson converter. Up until now it worked great. But then I needed my object to implement Serializable, because I need to store it in memcache of GAE. For some reason - when the class implements Serializable, things stop working. Restlet sends a different string representation from before, and I can't even print that string in the server. I tried printing its byte value, char-by-char and the first numbers are: 0xfffd 0xfffd 0x0000 0x0005 0x0073 0x0072 Thanks a lot!

    Read the article

  • Spring 3.0 making JSON response using jackson message converter

    - by dupdup
    i configure my messageconverter as Jackson's then class Foo{int x; int y} and in controller @ResponseBody public Foo method(){ return new Foo(3,4) } from that i m expecting to return a JSON string {x:'3',y:'4'} from server without any other configuration. but getting 404 error response to my ajax request If the method is annotated with @ResponseBody, the return type is written to the response HTTP body. The return value will be converted to the declared method argument type using HttpMessageConverters. Am I wrong ? or should I convert my response Object to Json string myself using serializer and then returning that string as response.(I could make string responses correctly) or should I make some other configurations ? like adding annotations for class Foo here is my conf.xml <bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="jacksonMessageConverter"/> </list> </property>

    Read the article

  • Json Jackson deserialization without inner classes

    - by Eto Demerzel
    Hi everyone, I have a question concerning Json deserialization using Jackson. I would like to deserialize a Json file using a class like this one: (taken from http://wiki.fasterxml.com/JacksonInFiveMinutes) public class User { public enum Gender { MALE, FEMALE }; public static class Name { private String _first, _last; public String getFirst() { return _first; } public String getLast() { return _last; } public void setFirst(String s) { _first = s; } public void setLast(String s) { _last = s; } } private Gender _gender; private Name _name; private boolean _isVerified; private byte[] _userImage; public Name getName() { return _name; } public boolean isVerified() { return _isVerified; } public Gender getGender() { return _gender; } public byte[] getUserImage() { return _userImage; } public void setName(Name n) { _name = n; } public void setVerified(boolean b) { _isVerified = b; } public void setGender(Gender g) { _gender = g; } public void setUserImage(byte[] b) { _userImage = b; } } A Json file can be deserialized using the so called "Full Data Binding" in this way: ObjectMapper mapper = new ObjectMapper(); User user = mapper.readValue(new File("user.json"), User.class); My problem is the usage of the inner class "Name". I would like to do the same thing without using inner classes. The "User" class would became like that: import Name; import Gender; public class User { private Gender _gender; private Name _name; private boolean _isVerified; private byte[] _userImage; public Name getName() { return _name; } public boolean isVerified() { return _isVerified; } public Gender getGender() { return _gender; } public byte[] getUserImage() { return _userImage; } public void setName(Name n) { _name = n; } public void setVerified(boolean b) { _isVerified = b; } public void setGender(Gender g) { _gender = g; } public void setUserImage(byte[] b) { _userImage = b; } } This means to find a way to specify to the mapper all the required classes in order to perform the deserialization. Is this possible? I looked at the documentation but I cannot find any solution. My need comes from the fact that I use the Javassist library to create such classes, and it does not support inner or anonymous classes. Thank you in advance

    Read the article

  • Spring MVC return ajax response using Jackson

    - by anshumn
    I have a scenario where I am filling a dropdown box in JSP through AJAX response from the server. In the controller, I am retuning a Collection of Product objects and have annotated the return type with @ResponseBody. Controller - @RequestMapping(value="/getServicesForMarket", method = RequestMethod.GET) public @ResponseBody Collection<Product> getServices(@RequestParam(value="marketId", required=true) int marketId) { Collection<Product> products = marketService.getProducts(marketId); return products; } And Product is @Entity @Table(name = "PRODUCT") public class Product implements Serializable { private static final long serialVersionUID = 1L; private int id; private Market market; private Service service; private int price; @Id @GeneratedValue(strategy = GenerationType.AUTO) public int getId() { return id; } public void setId(int id) { this.id = id; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name = "MARKET_ID") public Market getMarket() { return market; } public void setMarket(Market market) { this.market = market; } @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name = "SERVICE_ID") public Service getService() { return service; } public void setService(Service service) { this.service = service; } @Column(name = "PRICE") public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } } Service is @Entity @Table(name="SERVICE") public class Service implements Serializable { /** * */ private static final long serialVersionUID = 1L; private int id; private String name; private String description; @Id @GeneratedValue @Column(name="ID") public int getId() { return id; } public void setId(int id) { this.id = id; } @Column(name="NAME") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="DESCRIPTION") public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } } In the JSP, I need to get the data from the service field of Product also. So I in my JQuery callback function, I have written like product.service.description to get the data. It seems that by default Jackson is not mapping the associated service object (or any other custom object). Also I am not getting any exception. In the JSP, I do not get the data. It is working fine when I return Collection of some object which does not contain any other custom objects as its fields. Am I missing any settings for this to work? Thanks!

    Read the article

  • Handling Unknown JSON Properties with Jackson

    - by henrik_lundgren
    Hi, For deserializing json with unknown field into an object there's @JsonAnySetter. But what if I read such json into my object, modify some known fields and write it back to json? The unknown properties will be lost. How do I handle such cases? Is it possible to map an object or do I have to read the data into a JsonNode or Map?

    Read the article

  • Parse simple JSON with Jackson

    - by siik
    Here is my JSON: { "i": 53691, "s": "Something" } Here is my model: public class Test() { private int i; private String s; public setInt(int i){ this.i = i; } public setString(String s){ this.s = s; } // getters here } Here is my class for server's response: public class ServerResponse(){ private Test; public void setTest(Test test){ this.test = test;} public Test getTest(){ return Test; } } When I do: ObjectMapper mapper = new ObjectMapper(); mapper.readValue(json, serverResponse); I'm getting an exception like: JsonProcessingException: Unrecognized field "i" (Class MyClass), not marked as ignorable Please advice.

    Read the article

  • How can I enable Pascal casing by default when using Jackson JSON in Spring MVC?

    - by bhilstrom
    I have a project that uses Spring MVC to create and handle multiple REST endpoints. I'm currently working on using Jackson to automatically handle the seralization/deserialization of JSON using the @RequestBody and @ResponseBody annotations. I have gotten Jackson working, so I've got a starting point. My problem is that our old serialization was done manually and used Pascal casing instead of Camel casing ("MyVariable" instead of "myVariable"), and Jackson does Camel casing by default. I know that I can manually change the name for a variable using @JsonProperty. That being said, I do not consider adding "@JsonProperty" to all of my variables to be a viable long-term solution. Is there a way to make Jackson use Pascal casing when serializing and deserializing other than using the @JsonProperty annotation?

    Read the article

  • jackson failing to map empty array with No content to map to Object due to end of input

    - by ijabz
    I send a query to an api and map the json results to my classes using Jackson. When I get some results it works fine, but when there are no results it fails with java.io.EOFException: No content to map to Object due to end of input at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2766) at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2709) at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1854) at com.jthink.discogs.query.DiscogsServerQuery.mapQuery(DiscogsServerQuery.java:382) at com.jthink.discogs.query.SearchQuery.mapQuery(SearchQuery.java:37)* But the thing is the api isn't returning nothing at all, so I dont see why it is failing. Here is the query: http://api.discogs.com/database/search?page=1&type=release&release_title=nude+and+rude+the+best+of+iggy+pop this is what I get back { "pagination": { "per_page": 50, "pages": 1, "page": 1, "urls": {}, "items": 0 }, "results": [] } and here is the top level object Im trying to map to public class Search { private Pagination pagination; private Result[] results; public Pagination getPagination() { return pagination; } public void setPagination(Pagination pagination) { this.pagination = pagination; } public Result[] getResults() { return results; } public void setResults(Result[] results) { this.results = results; } } Im guessing the problem is something to do with the results array being returned being blank, but cant see what Im doing wrong EDIT: The comment below was correct, although I usually receive { "pagination": { "per_page": 50, "pages": 1, "page": 1, "urls": {}, "items": 0 }, "results": [] } and in these cases there is no problem but sometimes I seem to just get an empty String. Now Im wondering if the problem is how I read from the inputstream if (responseCode == HttpURLConnection.HTTP_OK) InputStreamReader in= new InputStreamReader(uc.getInputStream()); BufferedReader br= new BufferedReader(in); while(br.ready()) { String next = br.readLine(); sb.append(next); } return sb.toString(); } although I dont read until I get the response code, is it possible that the first time I call br.ready() that I call it before it is ready, and therefore I don't read the input EDIT 2: Changing above code to simply String line; while ((line = br.readLine()) != null) { sb.append(line); } resolved the issue.

    Read the article

  • how to store JSON into POJO using Jackson

    - by user2963680
    I am developing a module where i am using rest service to get data. i am not getting how to store JSON using Jackson and store it which has Queryparam also. Any help is really appreciated as I am new to this.I am trying to do server side filtering in extjs infinte grid which is sending the below request to rest service. when the page load first time, it sends http://myhost/mycontext/rest/populateGrid?_dc=9999999999999&page=1&start=0&limit=500 when you select filter on name and place, it sends http://myhost/mycontext/rest/populateGrid?_dc=9999999999999&filter=[{"type":"string","value":"Tom","field":"name"},{"type":"string","value":"London","field":"Location"}]&page=1&start=0&limit=500 I am trying to save this in POJO and then sending this to database to retrieve data. For this on rest side i have written something like this @Provider @Path("/rest") public interface restAccessPoint { @GET @Path("/populateGrid") @Produces({MediaType.APPLICATION_JSON}) public Response getallGridData(FilterJsonToJava filterparam,@QueryParam("page") String page,@QueryParam("start") String start,@QueryParam("limit") String limit); } public class FilterJsonToJava { @JsonProperty(value ="filter") private List<Filter> data; .. getter and setter below } public class Filter { @JsonProperty("type") private String type; @JsonProperty("value") private String value; @JsonProperty("field") private String field; ...getter and setters below } I am getting the below error The following warnings have been detected with resource and/or provider classes: WARNING: A HTTP GET method, public abstract javax.ws.rs.core.Response com.xx.xx.xx.xxxxx (com.xx.xx.xx.xx.json.FilterJsonToJava ,java.lang.String,java.lang.String,java.lang.String), should not consume any entity. com.xx.xx.xx.xx.json.FilterJsonToJava, and Java type class com.xx.xx.xx.FilterJsonToJava, and MIME media type application/octet-stream was not found [11/6/13 17:46:54:065] 0000001c ContainerRequ E The registered message body readers compatible with the MIME media type are: application/octet-stream com.sun.jersey.core.impl.provider.entity.ByteArrayProvider com.sun.jersey.core.impl.provider.entity.FileProvider com.sun.jersey.core.impl.provider.entity.InputStreamProvider com.sun.jersey.core.impl.provider.entity.DataSourceProvider com.sun.jersey.core.impl.provider.entity.RenderedImageProvider */* -> com.sun.jersey.core.impl.provider.entity.FormProvider ...

    Read the article

  • Make @JsonTypeInfo property optional

    - by Mark Peters
    I'm using @JsonTypeInfo to instruct Jackson to look in the @class property for concrete type information. However, sometimes I don't want to have to specify @class, particularly when the subtype can be inferred given the context. What's the best way to do that? Here's an example of the JSON: { "owner": {"name":"Dave"}, "residents":[ {"@class":"jacksonquestion.Dog","breed":"Greyhound"}, {"@class":"jacksonquestion.Human","name":"Cheryl"}, {"@class":"jacksonquestion.Human","name":"Timothy"} ] } and I'm trying to deserialize them into these classes (all in jacksonquestion.*): public class Household { private Human owner; private List<Animal> residents; public Human getOwner() { return owner; } public void setOwner(Human owner) { this.owner = owner; } public List<Animal> getResidents() { return residents; } public void setResidents(List<Animal> residents) { this.residents = residents; } } public class Animal {} public class Dog extends Animal { private String breed; public String getBreed() { return breed; } public void setBreed(String breed) { this.breed = breed; } } public class Human extends Animal { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } using this config: @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class") private static class AnimalMixin { } //... ObjectMapper objectMapper = new ObjectMapper(); objectMapper.getDeserializationConfig().addMixInAnnotations(Animal.class, AnimalMixin.class); Household household = objectMapper.readValue(json, Household.class); System.out.println(household); As you can see, the owner is declared as a Human, not an Animal, so I want to be able to omit @class and have Jackson infer the type as it normally would. When I run this though, I get org.codehaus.jackson.map.JsonMappingException: Unexpected token (END_OBJECT), expected FIELD_NAME: missing property '@class' that is to contain type id (for class jacksonquestion.Human) Since "owner" doesn't specify @class. Any ideas? One initial thought I had was to use @JsonTypeInfo on the property rather than the type. However, this cannot be leveraged to annotate the element type of a list.

    Read the article

  • JsonParseException on Valid JSON

    - by user2909602
    I am having an issue calling a RESTful service from my client code. I have written the RESTful service using CXF/Jackson, deployed to localhost, and tested using RESTClient successfully. Below is a snippet of the service code: @POST @Produces("application/json") @Consumes("application/json") @Path("/set/mood") public Response setMood(MoodMeter mm) { this.getMmDAO().insert(mm); return Response.ok().entity(mm).build(); } The model class and dao work successfully and the service itself works fine using RESTClient. However, when I attempt to call this service from Java Script, I get the error below on the server side: Caused by: org.codehaus.jackson.JsonParseException: Unexpected character ('m' (code 109)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') I have copied the client side code below. To make sure it has nothing to do with the JSON data itself, I used a valid JSON string (which works using RESTClient, JSON.parse() method, and JSONLint) in the vars 'json' (string) and 'jsonData' (JSON). Below is the Java Script code: var json = '{"mood_value":8,"mood_comments":"new comments","user_id":5,"point":{"latitude":37.292929,"longitude":38.0323323},"created_dtm":1381546869260}'; var jsonData = JSON.parse(json); $.ajax({ url: 'http://localhost:8080/moodmeter/app/service/set/mood', dataType: 'json', data: jsonData, type: "POST", contentType: "application/json" }); I've seen the JsonParseException a number of times on other threads, but in this case the JSON itself appears to be valid (and tested). Any thoughts are appreciated.

    Read the article

  • Turning a JSON list into a POJO

    - by Josh L
    I'm having trouble getting this bit of JSON into a POJO. I'm using Jackson configured like this: protected ThreadLocal<ObjectMapper> jparser = new ThreadLocal<ObjectMapper>(); public void receive(Object object) { try { if (object instanceof String && ((String)object).length() != 0) { ObjectDefinition t = null ; if (parserChoice==0) { if (jparser.get()==null) { jparser.set(new ObjectMapper()); } t = jparser.get().readValue((String)object, ObjectDefinition.class); } Object key = t.getKey(); if (key == null) return; transaction.put(key,t); } } catch (Exception e) { e.printStackTrace(); } } Here's the JSON that needs to be turned into a POJO: { "id":"exampleID1", "entities":{ "tags":[ { "text":"textexample1", "indices":[ 2, 14 ] }, { "text":"textexample2", "indices":[ 31, 36 ] }, { "text":"textexample3", "indices":[ 37, 43 ] } ] } And lastly, here's what I currently have for the java class: protected Entities entities; @JsonIgnoreProperties(ignoreUnknown = true) protected class Entities { public Entities() {} protected Tags tags; @JsonIgnoreProperties(ignoreUnknown = true) protected class Tags { public Tags() {} protected String text; public String getText() { return text; } public void setText(String text) { this.text = text; } }; public Tags getTags() { return tags; } public void setTags(Tags tags) { this.tags = tags; } }; //Getters & Setters ... I've been able to translate the more simple objects into a POJO, but the list has me stumped. Any help is appreciated. Thanks!

    Read the article

  • Warning: This class was probably produced by a broken compiler.

    - by Michal Dymel
    I have added Jacson libs to my android project and now I am getting such warnings in console: warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) I've tried to recompile libs, but it didn't help. Warnings are gone when I remove these libs from project. Everything is working fine on the device, but this annoys me ;) Do you know any solution?

    Read the article

  • How to get the ObjectId value from MongoDB?

    - by LVarayut
    I'm using Jongo with Play framework 2, java. I added some data into my MongoDB. {"_id" : ObjectId("538dafffbf6b562617252178"), ... } However, when I fetched the ObjectId from the database, it gave me like: de.undercouch.bson4jackson.types.ObjectId@484431ff instead of 538dafffbf6b562617252178. I don't quite understand how can I get the ObjectId value. My class is defined as following: public class Product { @JsonProperty("_id") protected String id; ... public Product() { } public String getId() { return id; } public void setId(String id) { this.id = id; } } EDIT In order to fetch the data, I simply use find() function provided by Jongo as following: public static Iterable<Product> findAll(){ return products().find().as(Product.class); }

    Read the article

  • Grails and googleJsonAPIService

    - by Calahad
    I am using the googleJsonAPIService to manipulate users (CRUD). This is how I get the Directory instance: def getBuilder() { def builder def httpTransport = googleJsonAPIService.makeTransport() def jsonFactory = googleJsonAPIService.makeJsonFactory() def requestInitialiser = googleJsonAPIService.getRequestInitialiser() builder = new Directory.Builder(httpTransport, jsonFactory, requestInitialiser); return builder } Directory getGoogleService() { Directory googleService = getBuilder().build() return googleService; } Once I have this service, I use it to get a user's details (in my own service) for example: def query = getGoogleService().users().get(id) return handleException { query.execute() } I manually populate a DTO with the result of that query, and this is where my question comes: Is there an elegant way to have this mapping (object returned to DTO) done automatically so all I have to do is pass the class of the object to be returned? This is the structure of the object returned by google : ["agreedToTerms":true,"changePasswordAtNextLogin":false, "creationTime":"2013-11-04T04:33:35.000Z", "emails":[{"address":"[email protected]","primary":true}],...]

    Read the article

1 2 3 4 5 6 7 8 9 10  | Next Page >