Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to write deserlizer java

package net.sghill.example;

import net.sghill.example.User;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.ObjectCodec;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;

import java.io.IOException;

public class UserDeserializer extends JsonDeserializer<User> {

    @Override
    public User deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
        ObjectCodec oc = jsonParser.getCodec();
        JsonNode node = oc.readTree(jsonParser);
        return new User(null, node.get("username").getTextValue(), node.get("password").getTextValue());
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: bootstrap 4 modal get event related target 
Java :: replace last char in string java 
Java :: java main method 
Java :: jframe change icon 
Java :: jframe in java 
Java :: how to import math lib in java 
Java :: convert date to offsetdatetime in java 
Java :: java remove trailing zeros from float 
Java :: android studio listview arrayadapter 
Java :: java summe array 
Java :: int to byte 
Java :: changer version java terminal 
Java :: mobile number validation to edittext in android 
Java :: java mp3 player 
Java :: java list distinct by object attribute 
Java :: double quotes in string java 
Java :: Java Queue Array Implementation 
Java :: image cropper implementation 
Java :: java add to map 
Java :: responseentity spring boot 
Java :: java print array backwards 
Java :: jpa enum as string 
Java :: java string regexp replace 
Java :: remove first and last character from string in java 
Java :: isanagram java 
Java :: android application class manifest 
Java :: 64 bit integer java 
Java :: java hash password 
Java :: java initialize string array 
Java :: java coalesce 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =