= JsonRepresentation
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A wrapper around _JsonNode_ that provides some additional helper methods.

== API

[source,java]
.JsonRepresentation.java
----
class JsonRepresentation {
  public static final DateTimeFormatter yyyyMMdd;
  public static final DateTimeFormatter yyyyMMddTHHmmssZ;
  public static final DateTimeFormatter _HHmmss;
  JsonRepresentation(JsonNode jsonNode)
  JsonRepresentation jsonAsMap(String keyValuePairsAsJson)
  JsonRepresentation newMap(String... keyValuePairs)
  JsonRepresentation newArray()
  JsonRepresentation newArray(int initialSize)
  JsonNode asJsonNode()
  int size()
  boolean isValue()     // <.>
  JsonRepresentation getRepresentation(String pathTemplate, Object... args)
  boolean isArray(String path)
  boolean isArray()
  JsonRepresentation getArray(String path)
  JsonRepresentation asArray()
  JsonRepresentation getArrayEnsured(String path)
  boolean isMap(String path)
  boolean isMap()
  JsonRepresentation getMap(String path)
  JsonRepresentation asMap()
  boolean isNumber(String path)
  boolean isNumber()
  Number asNumber()
  boolean isIntegralNumber(String path)     // <.>
  boolean isIntegralNumber()     // <.>
  java.util.Date getDate(String path)
  java.util.Date asDate()
  java.util.Date getDateTime(String path)
  java.util.Date asDateTime()
  java.util.Date getTime(String path)
  java.util.Date asTime()
  boolean isBoolean(String path)
  boolean isBoolean()
  Boolean getBoolean(String path)     // <.>
  Boolean asBoolean()     // <.>
  Byte getByte(String path)     // <.>
  Byte asByte()     // <.>
  Short getShort(String path)     // <.>
  Short asShort()     // <.>
  Character getChar(String path)     // <.>
  Character asChar()     // <.>
  boolean isInt(String path)
  boolean isInt()
  Integer getInt(String path)     // <.>
  Integer asInt()     // <.>
  boolean isLong(String path)
  boolean isLong()
  Long getLong(String path)     // <.>
  Long asLong()     // <.>
  Float getFloat(String path)     // <.>
  Float asFloat()     // <.>
  boolean isDecimal(String path)
  boolean isDecimal()
  Double getDouble(String path)     // <.>
  Double asDouble()     // <.>
  boolean isBigInteger(String path)
  boolean isBigInteger()
  BigInteger getBigInteger(String path)     // <.>
  BigInteger getBigInteger(String path, String formatRequested)     // <.>
  BigInteger asBigInteger()     // <.>
  BigInteger asBigInteger(String format)
  boolean isBigDecimal(String path)
  boolean isBigDecimal()
  BigDecimal getBigDecimal(String path)     // <.>
  BigDecimal getBigDecimal(String path, String formatRequested)     // <.>
  BigDecimal asBigDecimal()     // <.>
  BigDecimal asBigDecimal(String format)     // <.>
  boolean isString(String path)
  boolean isString()
  String getString(String path)     // <.>
  String asString()     // <.>
  String asArg()
  boolean isLink()
  boolean isLink(String path)
  boolean isLink(JsonNode node)
  LinkRepresentation getLink(String path)     // <.>
  LinkRepresentation asLink()     // <.>
  boolean isNull()
  Boolean isNull(String path)     // <.>
  JsonRepresentation getNull(String path)     // <.>
  JsonRepresentation asNull()     // <.>
  LinkRepresentation mapValueAsLink()     // <.>
  InputStream asInputStream()
  T as(Class<T> cls)     // <.>
  String asUrlEncoded()
  JsonRepresentation arrayAdd(Object value)
  JsonRepresentation arrayAdd(JsonRepresentation value)
  JsonRepresentation arrayAdd(String value)
  JsonRepresentation arrayAdd(JsonNode value)
  JsonRepresentation arrayAdd(long value)
  JsonRepresentation arrayAdd(int value)
  JsonRepresentation arrayAdd(double value)
  JsonRepresentation arrayAdd(float value)
  JsonRepresentation arrayAdd(boolean value)
  Stream<JsonRepresentation> streamArrayElements()
  Stream<T> streamArrayElements(Class<T> requiredType)
  JsonRepresentation arrayGet(int i)
  JsonRepresentation arraySetElementAt(int i, JsonRepresentation objectRepr)
  boolean mapHas(String key)
  JsonRepresentation mapPut(String key, List<Object> value)
  JsonRepresentation mapPut(String key, Object value)
  JsonRepresentation mapPutJsonRepresentation(String key, JsonRepresentation value)
  JsonRepresentation mapPutString(String key, String value)
  JsonRepresentation mapPutJsonNode(String key, JsonNode value)
  JsonRepresentation mapPutByte(String key, byte value)
  JsonRepresentation mapPutByteNullable(String key, Byte value)
  JsonRepresentation mapPutShort(String key, short value)
  JsonRepresentation mapPutShortNullable(String key, Short value)
  JsonRepresentation mapPutInt(String key, int value)
  JsonRepresentation mapPutIntNullable(String key, Integer value)
  JsonRepresentation mapPutLong(String key, long value)
  JsonRepresentation mapPutLongNullable(String key, Long value)
  JsonRepresentation mapPutFloat(String key, float value)
  JsonRepresentation mapPutFloatNullable(String key, Float value)
  JsonRepresentation mapPutDouble(String key, double value)
  JsonRepresentation mapPutDoubleNullable(String key, Double value)
  JsonRepresentation mapPutBoolean(String key, boolean value)
  JsonRepresentation mapPutBooleanNullable(String key, Boolean value)
  JsonRepresentation mapPutChar(String key, char value)
  JsonRepresentation mapPutCharNullable(String key, Character value)
  JsonRepresentation mapPutBigInteger(String key, BigInteger value)
  JsonRepresentation mapPutEntries(Iterable<Entry<String, JsonRepresentation>> entries)
  JsonRepresentation mapPutEntry(Entry<String, JsonRepresentation> entry)
  JsonRepresentation mapPutBigDecimal(String key, BigDecimal value)
  JsonRepresentation putFormat(String format)
  JsonRepresentation putExtendedFormat(String format)
  Stream<Map.Entry<String, JsonRepresentation>> streamMapEntries()
  JsonRepresentation ensureArray()     // <.>
  int hashCode()
  boolean equals(Object obj)
  String toString()
}
----

<.> xref:#isValue_[isValue()]
+
--
Node is a value (nb: could be _#isNull() null_ ).
--
<.> xref:#isIntegralNumber_String[isIntegralNumber(String)]
+
--
Is a long, an int or a _BigInteger_ .
--
<.> xref:#isIntegralNumber_[isIntegralNumber()]
+
--
Is a long, an int or a _BigInteger_ .
--
<.> xref:#getBoolean_String[getBoolean(String)]
+
--
Use _#isBoolean(String)_ to check first, if required.
--
<.> xref:#asBoolean_[asBoolean()]
+
--
Use _#isBoolean()_ to check first, if required.
--
<.> xref:#getByte_String[getByte(String)]
+
--
Use _#isIntegralNumber(String)_ to test if number (it is not possible to check if a byte, however).
--
<.> xref:#asByte_[asByte()]
+
--
Use _#isIntegralNumber()_ to test if number (it is not possible to check if a byte, however).
--
<.> xref:#getShort_String[getShort(String)]
+
--
Use _#isIntegralNumber(String)_ to check if number (it is not possible to check if a short, however).
--
<.> xref:#asShort_[asShort()]
+
--
Use _#isIntegralNumber()_ to check if number (it is not possible to check if a short, however).
--
<.> xref:#getChar_String[getChar(String)]
+
--
Use _#isString(String)_ to check if string (it is not possible to check if a character, however).
--
<.> xref:#asChar_[asChar()]
+
--
Use _#isString()_ to check if string (it is not possible to check if a character, however).
--
<.> xref:#getInt_String[getInt(String)]
+
--
Use _#isInt(String)_ to check first, if required.
--
<.> xref:#asInt_[asInt()]
+
--
Use _#isInt()_ to check first, if required.
--
<.> xref:#getLong_String[getLong(String)]
+
--
Use _#isLong(String)_ to check first, if required.
--
<.> xref:#asLong_[asLong()]
+
--
Use _#isLong()_ to check first, if required.
--
<.> xref:#getFloat_String[getFloat(String)]
+
--
Use _#isDecimal(String)_ to test if a decimal value
--
<.> xref:#asFloat_[asFloat()]
+
--
Use _#isNumber()_ to test if number (it is not possible to check if a float, however).
--
<.> xref:#getDouble_String[getDouble(String)]
+
--
Use _#isDecimal(String)_ to check first, if required.
--
<.> xref:#asDouble_[asDouble()]
+
--
Use _#isDecimal()_ to check first, if required.
--
<.> xref:#getBigInteger_String[getBigInteger(String)]
+
--
Use _#isBigInteger(String)_ to check first, if required.
--
<.> xref:#getBigInteger_String_String[getBigInteger(String, String)]
+
--
Use _#isBigInteger(String)_ to check first, if required.
--
<.> xref:#asBigInteger_[asBigInteger()]
+
--
Use _#isBigInteger()_ to check first, if required.
--
<.> xref:#getBigDecimal_String[getBigDecimal(String)]
+
--
Use _#isBigDecimal(String)_ to check first, if required.
--
<.> xref:#getBigDecimal_String_String[getBigDecimal(String, String)]
+
--
Use _#isBigDecimal(String)_ to check first, if required.
--
<.> xref:#asBigDecimal_[asBigDecimal()]
+
--
Use _#isBigDecimal()_ to check first, if required.
--
<.> xref:#asBigDecimal_String[asBigDecimal(String)]
+
--
Use _#isBigDecimal()_ to check first, if required.
--
<.> xref:#getString_String[getString(String)]
+
--
Use _#isString(String)_ to check first, if required.
--
<.> xref:#asString_[asString()]
+
--
Use _#isString()_ to check first, if required.
--
<.> xref:#getLink_String[getLink(String)]
+
--
Use _#isLink(String)_ to check first, if required.
--
<.> xref:#asLink_[asLink()]
+
--
Use _#isLink()_ to check first, if required.
--
<.> xref:#isNull_String[isNull(String)]
+
--
Indicates that the wrapped node has `null` value (ie _JsonRepresentation#isNull()_ ), or returns `null` if there was no node with the provided path.
--
<.> xref:#getNull_String[getNull(String)]
+
--
Either returns a xref:refguide:viewer:index/restfulobjects/applib/JsonRepresentation.adoc[JsonRepresentation] that indicates that the wrapped node has `null` value (ie _JsonRepresentation#isNull()_ ), or returns `null` if there was no node with the provided path.
--
<.> xref:#asNull_[asNull()]
+
--
Either returns a xref:refguide:viewer:index/restfulobjects/applib/JsonRepresentation.adoc[JsonRepresentation] that indicates that the wrapped node has `null` value (ie _JsonRepresentation#isNull()_ ), or returns `null` if there was no node with the provided path.
--
<.> xref:#mapValueAsLink_[mapValueAsLink()]
+
--
Convert a representation that contains a single node representing a link into a xref:refguide:viewer:index/restfulobjects/applib/LinkRepresentation.adoc[LinkRepresentation] .
--
<.> xref:#as_Class[as(Class)]
+
--
Convenience to simply "downcast".
--
<.> xref:#ensureArray_[ensureArray()]
+
--
A reciprocal of the behaviour of the automatic dereferencing of arrays that occurs when there is only a single instance.
--

== Members

[#isValue_]
=== isValue()

Node is a value (nb: could be _#isNull() null_ ).

[#isIntegralNumber_String]
=== isIntegralNumber(String)

Is a long, an int or a _BigInteger_ .

[#isIntegralNumber_]
=== isIntegralNumber()

Is a long, an int or a _BigInteger_ .

[#getBoolean_String]
=== getBoolean(String)

Use _#isBoolean(String)_ to check first, if required.

[#asBoolean_]
=== asBoolean()

Use _#isBoolean()_ to check first, if required.

[#getByte_String]
=== getByte(String)

Use _#isIntegralNumber(String)_ to test if number (it is not possible to check if a byte, however).

[#asByte_]
=== asByte()

Use _#isIntegralNumber()_ to test if number (it is not possible to check if a byte, however).

[#getShort_String]
=== getShort(String)

Use _#isIntegralNumber(String)_ to check if number (it is not possible to check if a short, however).

[#asShort_]
=== asShort()

Use _#isIntegralNumber()_ to check if number (it is not possible to check if a short, however).

[#getChar_String]
=== getChar(String)

Use _#isString(String)_ to check if string (it is not possible to check if a character, however).

[#asChar_]
=== asChar()

Use _#isString()_ to check if string (it is not possible to check if a character, however).

[#getInt_String]
=== getInt(String)

Use _#isInt(String)_ to check first, if required.

[#asInt_]
=== asInt()

Use _#isInt()_ to check first, if required.

[#getLong_String]
=== getLong(String)

Use _#isLong(String)_ to check first, if required.

[#asLong_]
=== asLong()

Use _#isLong()_ to check first, if required.

[#getFloat_String]
=== getFloat(String)

Use _#isDecimal(String)_ to test if a decimal value

[#asFloat_]
=== asFloat()

Use _#isNumber()_ to test if number (it is not possible to check if a float, however).

[#getDouble_String]
=== getDouble(String)

Use _#isDecimal(String)_ to check first, if required.

[#asDouble_]
=== asDouble()

Use _#isDecimal()_ to check first, if required.

[#getBigInteger_String]
=== getBigInteger(String)

Use _#isBigInteger(String)_ to check first, if required.

[#getBigInteger_String_String]
=== getBigInteger(String, String)

Use _#isBigInteger(String)_ to check first, if required.

[#asBigInteger_]
=== asBigInteger()

Use _#isBigInteger()_ to check first, if required.

[#getBigDecimal_String]
=== getBigDecimal(String)

Use _#isBigDecimal(String)_ to check first, if required.

[#getBigDecimal_String_String]
=== getBigDecimal(String, String)

Use _#isBigDecimal(String)_ to check first, if required.

[#asBigDecimal_]
=== asBigDecimal()

Use _#isBigDecimal()_ to check first, if required.

[#asBigDecimal_String]
=== asBigDecimal(String)

Use _#isBigDecimal()_ to check first, if required.

[#getString_String]
=== getString(String)

Use _#isString(String)_ to check first, if required.

[#asString_]
=== asString()

Use _#isString()_ to check first, if required.

[#getLink_String]
=== getLink(String)

Use _#isLink(String)_ to check first, if required.

[#asLink_]
=== asLink()

Use _#isLink()_ to check first, if required.

[#isNull_String]
=== isNull(String)

Indicates that the wrapped node has `null` value (ie _JsonRepresentation#isNull()_ ), or returns `null` if there was no node with the provided path.

[#getNull_String]
=== getNull(String)

Either returns a xref:refguide:viewer:index/restfulobjects/applib/JsonRepresentation.adoc[JsonRepresentation] that indicates that the wrapped node has `null` value (ie _JsonRepresentation#isNull()_ ), or returns `null` if there was no node with the provided path.

Use _#isNull(String)_ to check first, if required.

[#asNull_]
=== asNull()

Either returns a xref:refguide:viewer:index/restfulobjects/applib/JsonRepresentation.adoc[JsonRepresentation] that indicates that the wrapped node has `null` value (ie _JsonRepresentation#isNull()_ ), or returns `null` if there was no node with the provided path.

Use _#isNull()_ to check first, if required.

[#mapValueAsLink_]
=== mapValueAsLink()

Convert a representation that contains a single node representing a link into a xref:refguide:viewer:index/restfulobjects/applib/LinkRepresentation.adoc[LinkRepresentation] .

[#as_Class]
=== as(Class)

Convenience to simply "downcast".

In fact, the method creates a new instance of the specified type, which shares the underlying _#jsonNode jsonNode_ .

[#ensureArray_]
=== ensureArray()

A reciprocal of the behaviour of the automatic dereferencing of arrays that occurs when there is only a single instance.
