ARTEMIS-565 JSON fixes

This commit is contained in:
jbertram 2016-08-01 10:07:50 -05:00
parent f44e87f43e
commit 7917f4d2f2
2 changed files with 35 additions and 6 deletions

View File

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

View File

@ -69,7 +69,7 @@ public class ManagementHelperTest extends Assert {
String resource = RandomUtil.randomString(); String resource = RandomUtil.randomString();
String operationName = RandomUtil.randomString(); String operationName = RandomUtil.randomString();
int i = RandomUtil.randomInt(); long i = RandomUtil.randomInt();
String s = RandomUtil.randomString(); String s = RandomUtil.randomString();
double d = RandomUtil.randomDouble(); double d = RandomUtil.randomDouble();
boolean b = RandomUtil.randomBoolean(); boolean b = RandomUtil.randomBoolean();
@ -192,7 +192,7 @@ public class ManagementHelperTest extends Assert {
ManagementHelperTest.log.info("val1 type is " + Arrays.toString(val1)); ManagementHelperTest.log.info("val1 type is " + Arrays.toString(val1));
String key2 = RandomUtil.randomString(); 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)); ManagementHelperTest.log.info("val2 type is " + Arrays.toString(val2));