Class JsonUtils

java.lang.Object
com.aducid.sdk.util.JsonUtils

public class JsonUtils
extends java.lang.Object
JSON utilities. Created 19. 1. 2017 8:34:39
Author:
Radek Jira
  • Method Summary

    Modifier and Type Method Description
    static <T> T fromJson​(java.lang.String objectAsJson, java.lang.Class<T> clazz)
    Extracts object from JSON.
    static java.util.List<java.lang.String> stringListFromJson​(java.lang.String stringListAsJson)
    Extracts string list from JSON.
    static java.lang.String toJson​(java.lang.Object object)
    Writes object to JSON.
    static java.lang.String toJsonResult​(AducidClientException clientException)
    Writes client exception to JSON result.
    static java.lang.String toJsonResult​(java.lang.Object object)
    Writes object to JSON result.

    Methods inherited from class java.lang.Object

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

    • fromJson

      public static <T> T fromJson​(java.lang.String objectAsJson, java.lang.Class<T> clazz) throws AducidClientException

      Extracts object from JSON.

      Type Parameters:
      T - object type
      Parameters:
      objectAsJson - object as JSON
      clazz - required object
      Returns:
      extracted object
      Throws:
      AducidClientException - when error occurs during ADUCID client call
    • stringListFromJson

      public static java.util.List<java.lang.String> stringListFromJson​(java.lang.String stringListAsJson) throws AducidClientException

      Extracts string list from JSON.

      Parameters:
      stringListAsJson - string list as JSON
      Returns:
      list of strings
      Throws:
      AducidClientException - when error occurs during ADUCID client call
    • toJson

      public static java.lang.String toJson​(java.lang.Object object) throws AducidClientException

      Writes object to JSON.

      Parameters:
      object - object to write
      Returns:
      object as JSON
      Throws:
      AducidClientException - when error occurs during ADUCID client call
    • toJsonResult

      public static java.lang.String toJsonResult​(java.lang.Object object)

      Writes object to JSON result.

      Parameters:
      object - object to write
      Returns:
      result as JSON
    • toJsonResult

      public static java.lang.String toJsonResult​(AducidClientException clientException)

      Writes client exception to JSON result.

      Parameters:
      clientException - client exception to write
      Returns:
      client exception result as JSON