title: Get abstract syntax tree of JSON string
body: <p><strong>Problem Description</strong></p>
  
  <p>I am writing a simple JSON analyzer in order to achieve syntax analysis of JSON strings. I am receiving random structure JSON strings and I want to export the syntax structure. As result, I want to get a tree structure which describes the format of the JSON string (key, value, arrays etc) and types of every element. I've already found the syntax definition of the <a href="https://www.json.org/" rel="nofollow noreferrer">JSON</a> (described below)</p>
  
  <pre><code>object
      {}
      { members } 
  members
      pair
      pair , members
  pair
      string : value
  array
      []
      [ elements ]
  elements
      value
      value , elements
  value
      string
      number
      object
      array
      true
      false
      null 
  </code></pre>
  
  <p><strong>Example</strong></p>
  
  <p>JSON String: </p>
  
  <pre><code>{"widget": {
      "null": null,
      "window": {
           153: "This is string",
          "boolean": true,
          "int": 500,
          "float": 5.555
      }
  }}    
  </code></pre>
  
  <p>And I want to get something like:</p>
  
  <pre><code>{ KEY_STR : {
       KEY_STR : null
       KEY_ARRAY : {
          KEY_INT: VALUE_STR,
          KEY_STR: VALUE_BOOL,
          KEY_STR: VALUE_INT,
          KEY_STR: VALUE_FLOAT
       }
  }}
  </code></pre>
  
  <p>I am using JAVA with GSON library.</p>
  
  <p><strong>How I want to use that</strong></p>
  
  <p>I am interested to export the abstract tree in order to create my own messages automatically</p>
  
  <p><strong>My Question</strong></p>
  
  <p>I have started to implement that by using <a href="https://static.javadoc.io/com.google.code.gson/gson/2.6.2/com/google/gson/JsonParser.html" rel="nofollow noreferrer">JsonParser</a>. I am parsing the JSON object and then I am defining for every key and value the type. But I am wondering if I am on a good way or I am discovering the wheel. Is there anything already exist to export the abstract syntax tree or I should implement that by myself?    </p>