简体   繁体   中英

parsing JSON with conditional operators and converting to Elasticsearch language java

I have JSON with conditional operators like:

{
  "or": [
    {
      "and": [
        {
          "ge": [
            "A",
            10
          ]
        },
        {
          "eq": [
            "B",
            20
          ]
        }
      ]
    },
    {
      "lt": [
        "C",
        30
      ]
    },
    {
      "ne": [
        "D",
        50
      ]
    },
    {
      "and": []
    },
    {
      "or": []
    }
  ]
}

I want to parse the JSON and convert to elasticsearch querying language. But I should be able de-serialize the input JSON first. what is the better way to do it. Using recursive?? If I should use recursive methods what would be the code snippet to build a recursive method.

Well, deserialization is transforming data from the wire (filesystem, network, etc), to a data format the program can use, and parsing is transforming data from one format to another. Two different things. But I am thinking that parsing is probably what you were referring to.

How to parse JSON in Java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM