This closes #692

This commit is contained in:
Clebert Suconic 2016-08-01 12:08:47 -04:00
commit 57f79cae0a
2 changed files with 35 additions and 6 deletions

View File

@ -126,6 +126,21 @@ public final class JsonUtil {
else if (innerVal instanceof JsonString) {
innerVal = ((JsonString)innerVal).getString();
}
else if (innerVal == JsonValue.FALSE) {
innerVal = Boolean.FALSE;
}
else if (innerVal == JsonValue.TRUE) {
innerVal = Boolean.TRUE;
}
else if (innerVal instanceof JsonNumber) {
JsonNumber jsonNumber = (JsonNumber)innerVal;
if (jsonNumber.isIntegral()) {
innerVal = jsonNumber.longValue();
}
else {
innerVal = jsonNumber.doubleValue();
}
}
else if (innerVal instanceof JsonObject) {
Map<String, Object> innerMap = new HashMap<>();
JsonObject o = (JsonObject) innerVal;
@ -135,10 +150,6 @@ public final class JsonUtil {
}
innerVal = innerMap;
}
else if (innerVal instanceof JsonNumber) {
JsonNumber jsonNumber = (JsonNumber)innerVal;
innerVal = jsonNumber.longValue();
}
if (CompositeData.class.getName().equals(key)) {
Object[] data = (Object[]) innerVal;
CompositeData[] cds = new CompositeData[data.length];
@ -155,6 +166,24 @@ public final class JsonUtil {
array[i] = map;
}
else if (val instanceof JsonString) {
array[i] = ((JsonString)val).getString();
}
else if (val == JsonValue.FALSE) {
array[i] = Boolean.FALSE;
}
else if (val == JsonValue.TRUE) {
array[i] = Boolean.TRUE;
}
else if (val instanceof JsonNumber) {
JsonNumber jsonNumber = (JsonNumber)val;
if (jsonNumber.isIntegral()) {
array[i] = jsonNumber.longValue();
}
else {
array[i] = jsonNumber.doubleValue();
}
}
else {
if (val == JsonValue.NULL) {
array[i] = null;

View File

@ -69,7 +69,7 @@ public class ManagementHelperTest extends Assert {
String resource = RandomUtil.randomString();
String operationName = RandomUtil.randomString();
int i = RandomUtil.randomInt();
long i = RandomUtil.randomInt();
String s = RandomUtil.randomString();
double d = RandomUtil.randomDouble();
boolean b = RandomUtil.randomBoolean();
@ -192,7 +192,7 @@ public class ManagementHelperTest extends Assert {
ManagementHelperTest.log.info("val1 type is " + Arrays.toString(val1));
String key2 = RandomUtil.randomString();
Integer[] val2 = new Integer[]{1, 2, 3, 4, 5};
Long[] val2 = new Long[]{1L, 2L, 3L, 4L, 5L};
ManagementHelperTest.log.info("val2 type is " + Arrays.toString(val2));