Class JSONUtils
java.lang.Object
org.deltava.util.JSONUtils
A utility class for dealing with JSON objects.
- Since:
- 7.3
- Version:
- 12.1
- Author:
- Luke
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidensureArrayPresent(org.json.JSONObject o, Object... names) Ensures a JSON object has certain array properties populated.static org.json.JSONObjectformat(GeoLocation loc) Converts a location into a Google Maps LatLngLiteral JSON object.static org.json.JSONObjectConverts a Runway into a JSON object.static org.json.JSONObjectFormats an Airline into a JSON object.static org.json.JSONObjectFormats an Airport into a JSON object.static org.json.JSONObjectformat(ScheduleEntry se) Formats a ScheduleEntry into a JSON object.static org.json.JSONObjectformat(FlightStatsEntry fse) Converts a FlightStatsEntry to JSON.static org.json.JSONObjectformatDate(Instant dt) Converts an Instant into a JSON object with day/month/year components.static org.json.JSONObjectformatTime(ZonedDateTime zdt, String fmtPattern) Converts a ZonedDateTime to a JSON object with hour, minute, second and millisecond components.static org.json.JSONArraytoLL(GeoLocation loc) Converts a location into a MapbOX LngLat JSON array.
-
Method Details
-
ensureArrayPresent
Ensures a JSON object has certain array properties populated.JSONObject.accumulate(String, Object)will not create an Array if only a single call is made, therefore this method will translate a JSON property that is not an Array into a single-value JSONArray.- Parameters:
o- the JSONObjectnames- the property names
-
format
Converts a location into a Google Maps LatLngLiteral JSON object.- Parameters:
loc- a GeoLocation- Returns:
- a JSONObject
-
toLL
Converts a location into a MapbOX LngLat JSON array.- Parameters:
loc- a GeoLocation- Returns:
- a JSONArray
-
format
Formats an Airport into a JSON object.- Parameters:
a- an Airport- Returns:
- a JSONObject
-
format
Formats an Airline into a JSON object.- Parameters:
al- an Airline- Returns:
- a JSONObject
-
format
Formats a ScheduleEntry into a JSON object.- Parameters:
se- a ScheduleEntry- Returns:
- a JSONObject
-
formatDate
Converts an Instant into a JSON object with day/month/year components.- Parameters:
dt- an Instant- Returns:
- a JSONobject
-
formatTime
Converts a ZonedDateTime to a JSON object with hour, minute, second and millisecond components.- Parameters:
zdt- a ZonedDateTimefmtPattern- an optional formatter for the text property- Returns:
- a JSONObject
-
format
Converts a FlightStatsEntry to JSON.- Parameters:
fse- a FlightStatsEntry- Returns:
- a JSONOebject
-