Class JsonParser

java.lang.Object
de.monticore.symboltable.serialization.JsonParser

public class JsonParser extends Object
Parses serialized JSON Strings into an intermediate JSON data structure. This data structure can then be used, e.g., to build Java objects with their builders.
  • Constructor Details

    • JsonParser

      public JsonParser()
  • Method Details

    • parse

      public static JsonElement parse(String s)
      Parses a given String encoded in JSON to a JsonElement. This method should be used if the Json type (i.e., Object, Array,...) of the encoded JSON is unclear.
      Parameters:
      s -
      Returns:
    • parseJsonObject

      public static JsonObject parseJsonObject(String json)
      Parses a given String encoded in JSON to a JsonObject. Parsing of the String fails with an error if the encoded String cannot be parsed into a Json object.
      Parameters:
      json -
      Returns:
    • parseJsonArray

      public static JsonArray parseJsonArray(String json)
      Parses a given String encoded in JSON to a JsonArray. Parsing of the String fails with an error if the encoded String cannot be parsed into a Json array.
      Parameters:
      json -
      Returns:
    • parseJson

      public static JsonElement parseJson(JsonLexer lexer)
      parses any json using the passed lexer.
      Parameters:
      lexer -
      Returns:
    • parseJsonObject

      protected static JsonObject parseJsonObject(JsonLexer lexer)
      Parses a Json Object with the passed lexer
      Parameters:
      lexer -
      Returns:
    • parseJsonArray

      protected static JsonArray parseJsonArray(JsonLexer lexer)
      Parses a Json array by using the passed lexer
      Parameters:
      lexer -
      Returns:
    • enableObjectMemberTracing

      public static void enableObjectMemberTracing()
      If object member tracing is enabled, getter-methods of Json objects are tracked to identify, if any members have been forgotten during deserialization
    • disableObjectMemberTracing

      public static void disableObjectMemberTracing()
      Disables object member tracing.
      See Also:
    • peekNextNonWhiteSpace

      protected static JsonToken peekNextNonWhiteSpace(JsonLexer lexer)
      reads all whitespace tokens until the next non-whitespace token. This is returned, but not consumed. If the method is called when the lexer has already reached the end of the document, it returns "null". If the end of the document occurs during consumption of whitespaces, a whitespace token is returned.
      Parameters:
      lexer -
      Returns:
    • pollNextNonWhiteSpace

      protected static JsonToken pollNextNonWhiteSpace(JsonLexer lexer)
      reads all whitespace tokens until the next non-whitespace token. This is returned and consumed. If the method is called when the lexer has already reached the end of the document, it returns "null". If the end of the document occurs during consumption of whitespaces, a whitespace token is returned.
      Parameters:
      lexer -
      Returns: