org.openstreetmap.josm.plugins.streetside.utils.api

## Class JsonDecoder

- java.lang.Object
- - org.openstreetmap.josm.plugins.streetside.utils.api.JsonDecoder

-     public final class JsonDecoder
      extends Object

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `JsonDecoder()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) static double[]` | `decodeDoublePair(javax.json.JsonArray json)` Decodes a pair of double values, which are stored in a `JsonArray` of exactly size 2.
    `static <T> Collection<T>` | `decodeFeatureCollection(javax.json.JsonObject json, Function<javax.json.JsonObject,T> featureDecoder)` Parses a given `JsonObject` as a GeoJSON FeatureCollection into a `Collection` of the desired Java objects.
    `(package private) static LatLon` | `decodeLatLon(javax.json.JsonArray json)` Decodes a `JsonArray` of exactly size 2 to a `LatLon` instance.
    `(package private) static Long` | `decodeTimestamp(String timestamp)` Decodes a timestamp formatted as a `String` to the equivalent UNIX epoch timestamp (number of milliseconds since 1970-01-01T00:00:00.000+0000).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JsonDecoder

          private JsonDecoder()

  - ### Method Detail

    - #### decodeFeatureCollection

          public static <T> Collection<T> decodeFeatureCollection(javax.json.JsonObject json,
                                                                  Function<javax.json.JsonObject,T> featureDecoder)

      Parses a given `JsonObject` as a GeoJSON FeatureCollection into a `Collection` of the desired Java objects. The method, which converts the GeoJSON features into Java objects is given as a parameter to this method.
      Type Parameters:
        `T` - feature type
      Parameters:
        `json` - the `JsonObject` to be parsed
        `featureDecoder` - feature decoder which transforms JSON objects to Java objects
      Returns:
        a `Collection` which is parsed from the given `JsonObject`, which contains GeoJSON. Currently a `HashSet` is used, but please don't rely on it, this could change at any time without prior notice. The return value will not be `null`.

    - #### decodeLatLon

          static LatLon decodeLatLon(javax.json.JsonArray json)

      Decodes a `JsonArray` of exactly size 2 to a `LatLon` instance. The first value in the `JsonArray` is treated as longitude, the second one as latitude.
      Parameters:
        `json` - the `JsonArray` containing the two numbers
      Returns:
        the decoded `LatLon` instance, or `null` if the parameter is not a `JsonArray` of exactly size 2 containing two `JsonNumber`s.

    - #### decodeDoublePair

          static double[] decodeDoublePair(javax.json.JsonArray json)

      Decodes a pair of double values, which are stored in a `JsonArray` of exactly size 2.
      Parameters:
        `json` - the `JsonArray` containing the two values
      Returns:
        a double array which contains the two values in the same order, or `null` if the parameter was not a `JsonArray` of exactly size 2 containing two `JsonNumber`s

    - #### decodeTimestamp

          static Long decodeTimestamp(String timestamp)

      Decodes a timestamp formatted as a `String` to the equivalent UNIX epoch timestamp (number of milliseconds since 1970-01-01T00:00:00.000+0000).
      Parameters:
        `timestamp` - the timestamp formatted according to the format `yyyy-MM-dd'T'HH:mm:ss.SSSX`
      Returns:
        the point in time as a `Long` value representing the UNIX epoch time, or `null` if the parameter does not match the required format (this also triggers a warning via `Logging.warn(Throwable)`), or the parameter is `null`.

JOSM Plugins