Class JsonHelper


  • public class JsonHelper
    extends java.lang.Object
    Provides helper methods for JSON.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Value mapJsonResponse​(com.smartgridready.ns.v0.JMESPathMapping jmesPathMapping, java.lang.String response)
      Evaluates a JMESPath mapping on a JSON string and returns as SGr value.
      static Value parseJsonResponse​(java.lang.String jmesPath, java.lang.String jsonResp)
      Evaluates a JMESPath expression on a JSON string and returns as SGr value.
      static Value parseJsonResponseWithJsonata​(java.lang.String jsonataExpression, java.lang.String jsonResp)
      Evaluates a JSONata expression on a JSON string and returns as SGr value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • parseJsonResponse

        public static Value parseJsonResponse​(java.lang.String jmesPath,
                                              java.lang.String jsonResp)
                                       throws com.smartgridready.driver.api.common.GenDriverException
        Evaluates a JMESPath expression on a JSON string and returns as SGr value.
        Parameters:
        jmesPath - the JMESPath expression
        jsonResp - the JSON string
        Returns:
        an instance of JsonValue
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - when an error occurred during parsing
      • parseJsonResponseWithJsonata

        public static Value parseJsonResponseWithJsonata​(java.lang.String jsonataExpression,
                                                         java.lang.String jsonResp)
                                                  throws com.smartgridready.driver.api.common.GenDriverException
        Evaluates a JSONata expression on a JSON string and returns as SGr value.
        Parameters:
        jsonataExpression - the JSONata expression
        jsonResp - the JSON string
        Returns:
        an instance of JsonValue
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - when an error occurred during parsing
      • mapJsonResponse

        public static Value mapJsonResponse​(com.smartgridready.ns.v0.JMESPathMapping jmesPathMapping,
                                            java.lang.String response)
                                     throws com.smartgridready.driver.api.common.GenDriverException
        Evaluates a JMESPath mapping on a JSON string and returns as SGr value.
        Parameters:
        jmesPathMapping - the JMESPath mapping
        response - the JSON string
        Returns:
        an instance of JsonValue
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - when an error occurred during parsing and mapping