From c50adc2a3f1f397e3d697cd5eb12d415e99b934a Mon Sep 17 00:00:00 2001 From: cholin-bmc Date: Tue, 7 Mar 2017 14:38:57 -0800 Subject: [PATCH] Add support for 'any' type conversion to JSON --- src/main/java/net/rcarz/jiraclient/Field.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/net/rcarz/jiraclient/Field.java b/src/main/java/net/rcarz/jiraclient/Field.java index 0101914..b30687b 100644 --- a/src/main/java/net/rcarz/jiraclient/Field.java +++ b/src/main/java/net/rcarz/jiraclient/Field.java @@ -732,6 +732,20 @@ public final class Field { throw new JiraException("Field '" + name + "' expects a Numeric value"); } return value; + } else if (m.type.equals("any")) { + if (value == null) + return JSONNull.getInstance(); + else if (value instanceof List) + return toJsonMap((List)value); + else if (value instanceof ValueTuple) { + JSONObject json = new JSONObject(); + ValueTuple tuple = (ValueTuple)value; + json.put(tuple.type, tuple.value.toString()); + return json.toString(); + } else if (value instanceof TimeTracking) + return ((TimeTracking) value).toJsonObject(); + + return value; } throw new UnsupportedOperationException(m.type + " is not a supported field type");