Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class JsonValues

  1. Object
  2. JsonValues

Conversions the generated @Mapped mappers share: the lenient readers for @JsonFormat fields, ISO-8601 dates computed by arithmetic, and the path prefixing of a nested failure. Called only from generated code.

Nothing here consults a locale or a time zone: neither is guaranteed on a device, and a wire format must not depend on the phone’s settings. Dates are always written in UTC.

Methods

public static long toLong(Object v)A JSON number, or a string holding one, as a long.
public static long toIntegral(Object v, long min, long max)A JSON whole number in [min, max], for an array element of an integral type: a fraction or a value out of range is refused rather than truncated, as the server’s codec refuses it.
public static Object object(Mapper mapper, Object json)json read by mapper, which must be a JSON object.
public static double toDouble(Object v)A JSON number, or a string holding one, as a double.
public static Date toDate(Object v)A JSON date in either shape: epoch milliseconds (a number or a numeric string) or an ISO-8601 string – a date alone, or a date and time with optional fraction and Z or numeric offset.
public static String formatIso(Date d)Formats d as yyyy-MM-ddTHH:mm:ss.SSSZ in UTC.
public static long parseIso(String s)Parses an ISO-8601 date or date-time to epoch milliseconds.
public static IllegalArgumentException at(String path, IllegalArgumentException e)Prefixes a nested failure with the location it happened at.

Inherited methods

Method details

toLong

public static long toLong(Object v)
A JSON number, or a string holding one, as a long.

Throws

IllegalArgumentException
when the value is neither

toIntegral

public static long toIntegral(Object v, long min, long max)
A JSON whole number in [min, max], for an array element of an integral type: a fraction or a value out of range is refused rather than truncated, as the server’s codec refuses it.

Throws

IllegalArgumentException
when the value is not such a number

object

public static Object object(Mapper mapper, Object json)
json read by mapper, which must be a JSON object.

Throws

IllegalArgumentException
when json is not an object

toDouble

public static double toDouble(Object v)
A JSON number, or a string holding one, as a double.

Throws

IllegalArgumentException
when the value is neither

toDate

public static Date toDate(Object v)
A JSON date in either shape: epoch milliseconds (a number or a numeric string) or an ISO-8601 string – a date alone, or a date and time with optional fraction and Z or numeric offset.

Throws

IllegalArgumentException
when the value is neither

formatIso

public static String formatIso(Date d)
Formats d as yyyy-MM-ddTHH:mm:ss.SSSZ in UTC.

parseIso

public static long parseIso(String s)
Parses an ISO-8601 date or date-time to epoch milliseconds. A value with no offset is read as UTC.

Throws

IllegalArgumentException
when s is not ISO-8601

at

public static IllegalArgumentException at(String path, IllegalArgumentException e)
Prefixes a nested failure with the location it happened at. A message that already starts with a $ path is joined to it, so a failure three levels down reads $.order.items[2].due: required member is missing.