Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

string to pojo java

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;

public class TestJackson {

public static void main(String[] args) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        String testJson = "{
" + "  "user": {
" + "    "0": {
" + "      "firstName": "Monica",
" + "      "lastName": "Belluci"
" + "    },
" + "    "1": {
" + "      "firstName": "John",
" + "      "lastName": "Smith"
" + "    },
" + "    "2": {
" + "      "firstName": "Owen",
" + "      "lastName": "Hargreaves"
" + "    }
" + "  }
" + "}";
        User readValue = mapper.readValue(testJson, User.class);
        System.out.println("readValue = " + readValue);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #string #pojo #java
ADD COMMENT
Topic
Name
3+6 =