com.h3c.util.json

## Interface JsonCodec<T>

- Type Parameters:
    `T` - Type of a particular object to be encoded/decoded
  All Known Implementing Classes:
    AbstractJsonCodec, AbstractMetricDescriptorCodec, ActionCodec, AlertCodec, AlertTopicCodec, AlertTopicListenerCodec, ARPEntryCodec, AuditLogCodec, ConfigCodec, ControllerStatsCodec, CounterDescriptorCodec, CounterMetricCodec, DataPathInfoCodec, DpSuppressedPortsCodec, GaugeDescriptorCodec, GaugeMetricCodec, HistogramDescriptorCodec, HistogramMetricCodec, InstructionCodec, LicenseCodec, LinkCodec, MatchFieldCodec, MBodyExperimenterCodec, MBodyFlowStatsCodec, MBodyGroupDescStatsCodec, MBodyGroupFeaturesCodec, MBodyGroupStatsCodec, MBodyMeterFeaturesCodec, MBodyMeterStatsCodec, MBodyPortStatsCodec, MeterCodec, MeterDescriptorCodec, MeterMetricCodec, MetricUpdateCodec, NetworkNodeCodec, OfJsonCodec, OfmExperimenterCodec, OfmFlowModCodec, OfmGroupModCodec, OfmMeterModCodec, PortCodec, RatioGaugeDescriptorCodec, RatioGaugeMetricCodec, RegionCodec, ReportContentCodec, RollingCounterDescriptorCodec, RollingCounterMetricCodec, SystemInformationCodec, TimerDescriptorCodec, TimerMetricCodec, TopologyClusterCodec, TopologyPathCodec

      public interface JsonCodec<T>

  A generic Json codec interface for a given POJO class.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `decode(com.fasterxml.jackson.databind.node.ObjectNode node)` Decodes the JSON into a typed POJO.
    `T` | `decode(String json)` Decodes the JSON string into a typed POJO.
    `List<T>` | `decodeList(String json)` Decodes the JSON string into a typed list of POJO.
    `com.fasterxml.jackson.databind.node.ObjectNode` | `encode(T pojo)` Encodes the given POJO to its JSON representation.
    `String` | `encode(T pojo, boolean prettyPrint)` Encodes the given POJO to its JSON string representation.
    `com.fasterxml.jackson.databind.node.ArrayNode` | `encodeList(Collection<T> pojos)` Encodes the collection of POJOs to their JSON representation.
    `String` | `encodeList(Collection<T> pojos, boolean prettyPrint)` Encodes the collection of POJOs to their JSON string representation.
    `String` | `root()` Returns the root element's singular name.
    `String` | `roots()` Returns the root element's plural name.

- - ### Method Detail

    - #### root

          String root()

      Returns the root element's singular name.
      Returns:
        the root element's singular name

    - #### roots

          String roots()

      Returns the root element's plural name.
      Returns:
        the root element's plural name

    - #### encode

          String encode(T pojo,
                      boolean prettyPrint)

      Encodes the given POJO to its JSON string representation.
      Parameters:
        `pojo` - POJO to encode
        `prettyPrint` - Human-readable formatted JSON if true, single-line JSON otherwise
      Returns:
        JSON string representation of POJO

    - #### encodeList

          String encodeList(Collection<T> pojos,
                          boolean prettyPrint)

      Encodes the collection of POJOs to their JSON string representation.
      Parameters:
        `pojos` - list of POJO's to encode
        `prettyPrint` - human-readable formatted JSON if true, single-line JSON otherwise
      Returns:
        JSON string representation of the list of POJO's

    - #### decode

          T decode(String json)

      Decodes the JSON string into a typed POJO.
      Parameters:
        `json` - JSON string representation of the typed POJO
      Returns:
        typed POJO

    - #### decodeList

          List<T> decodeList(String json)

      Decodes the JSON string into a typed list of POJO.
      Parameters:
        `json` - JSON string representation of the typed list of POJOs
      Returns:
        typed list of POJOs

    - #### encode

          com.fasterxml.jackson.databind.node.ObjectNode encode(T pojo)

      Encodes the given POJO to its JSON representation.
      Parameters:
        `pojo` - POJO to encode
      Returns:
        ObjectNode representation of POJO. This does not have a "top" root

    - #### decode

          T decode(com.fasterxml.jackson.databind.node.ObjectNode node)

      Decodes the JSON into a typed POJO.
      Parameters:
        `node` - JSON representation of the typed POJO. This does not have a "top" root
      Returns:
        typed POJO

    - #### encodeList

          com.fasterxml.jackson.databind.node.ArrayNode encodeList(Collection<T> pojos)

      Encodes the collection of POJOs to their JSON representation.
      Parameters:
        `pojos` - list of POJO's to encode
      Returns:
        ArrayNode representation of the list of POJO's. This does not have the "top" root

Copyright © 2014. All Rights Reserved.