com.h3c.sdn.json

## Interface JsonService

-     public interface JsonService

  An OSGi service for encoding and decoding POJOs to and from their corresponding JSON representations. This service merely OSGifies the `JSON` facade.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `fromJson(String json, Class<T> pojo)` Convert the given JSON string to the given typed POJO.
    `<T> List<T>` | `fromJsonList(String json, Class<T> pojo)` Convert the given JSON string to a typed list of POJO's.
    `<T> String` | `toJson(T pojo, boolean prettyPrint)` Convert a POJO to its JSON representation.
    `<T> String` | `toJsonList(Collection<T> pojos, Class<T> pojo, boolean prettyPrint)` Convert a collection of POJO's into its JSON representation.

- - ### Method Detail

    - #### fromJson

          <T> T fromJson(String json,
                       Class<T> pojo)

      Convert the given JSON string to the given typed POJO.
      Parameters:
        `json` - JSON string representing an instance of the given POJO class
        `pojo` - POJO class of the given JSON string
      Returns:
        POJO instance represented by the JSON string

    - #### fromJsonList

          <T> List<T> fromJsonList(String json,
                                 Class<T> pojo)

      Convert the given JSON string to a typed list of POJO's.
      Parameters:
        `json` - JSON string representing a typed list of POJO's
        `pojo` - POJO class of the given JSON string
      Returns:
        typed list of POJO's represented by the JSON string

    - #### toJson

          <T> String toJson(T pojo,
                          boolean prettyPrint)

      Convert a POJO to its JSON representation.
      Parameters:
        `pojo` - POJO instance to convert
        `prettyPrint` - human-readable formatted JSON if true, single-line JSON otherwise
      Returns:
        JSON string representation of POJO

    - #### toJsonList

          <T> String toJsonList(Collection<T> pojos,
                              Class<T> pojo,
                              boolean prettyPrint)

      Convert a collection of POJO's into its JSON representation.
      Parameters:
        `pojos` - collection of POJO's
        `pojo` - class of POJO
        `prettyPrint` - human-readable formatted JSON if true, single-line JSON otherwise
      Returns:
        JSON string representation of the list of POJO's

Copyright © 2014. All Rights Reserved.