0

I have this rest result in url:"http:....:

{ took: 48,
    timed_out: false,
       _shards: {
    total: 5,
    successful: 5,
    failed: 0
    },
    hits: {
    total: 111,
    max_score: 1,
    hits: [
    {
    _index: "errors",
    _type: "error",
    _id: "AV0Sd2dn-sq8yPidLBWo",
    _score: 1,
    _source: {
    date: "16:54:46,215",
    path: "c:/logstash.log",
    @timestamp: "2017-07-05T11:16:40.560Z",
    level: "ERROR",
    @version: "1",
    host: "User",
    message:
    "16:54:46,215 ERROR [stderr] (ServerService Thread Pool -- 42) ch.qos.logback.core.joran.spi.JoranException: Problem parsing XML document. See previously reported errors."

I want to retrieve just this result and convert it to a list of objects that contains juste: date,level and message.

hits: [
        {
        _index: "errors",
        _type: "error",
        _id: "AV0Sd2dn-sq8yPidLBWo",
        _score: 1,
        _source: {
        date: "16:54:46,215",
        path: "c:/logstash.log",
        @timestamp: "2017-07-05T11:16:40.560Z",
        level: "ERROR",
        @version: "1",
        host: "User",
        message: [
        "16:54:46,215 ERROR [stderr] (ServerService Thread Pool -- 42) ch.qos.logback.core.joran.spi.JoranException: Problem parsing XML document. See previously reported errors."
]}}

----Edit--- this is my class:

public class Error {
 private String date;
 private String level;
 private String message;
}

So i want create an object Error from the reslt of json.Exactly from this

_source: {
    date: "16:54:46,215",
    path: "c:/logstash.log",
    @timestamp: "2017-07-05T11:16:40.560Z",
    level: "ERROR",
    @version: "1",
    host: "User",
    message:
    "16:54:46,215 ERROR [stderr] (ServerService Thread Pool -- 42) ch.qos.logback.core.joran.spi.JoranException: Problem parsing XML document. See previously reported errors."

Any help is greatly appreciate.

rbaha
  • 140
  • 1
  • 11

0 Answers0