protected void writeEmptyCollection(Level level, String keyName){
level.getJsonObjectBuilder().add(keyName, Json.createArrayBuilder());
}
protected void addValueToObject(Level level, String keyName, Object value, QName schemaType){
JsonObjectBuilder jsonObjectBuilder = level.getJsonObjectBuilder();
if(value == NULL){
jsonObjectBuilder.addNull(keyName);
}else if(value instanceof Integer){
jsonObjectBuilder.add(keyName, (Integer)value);
}else if(value instanceof BigDecimal){
jsonObjectBuilder.add(keyName, (BigDecimal)value);
}else if(value instanceof BigInteger){
jsonObjectBuilder.add(keyName, (BigInteger)value);
}else if(value instanceof Boolean){
jsonObjectBuilder.add(keyName, (Boolean)value);
}else if(value instanceof Character){
jsonObjectBuilder.add(keyName, (Character)value);
}else if(value instanceof Double){
jsonObjectBuilder.add(keyName, (Double)value);
}else if(value instanceof Float){
jsonObjectBuilder.add(keyName, (Float)value);
}else if(value instanceof Long){
jsonObjectBuilder.add(keyName, (Long)value);
}else if(value instanceof String){
jsonObjectBuilder.add(keyName, (String)value);
}else{
ConversionManager conversionManager = getConversionManager();
String convertedValue = (String) conversionManager.convertObject(value, CoreClassConstants.STRING, schemaType);
Class theClass = conversionManager.javaType(schemaType);
if((schemaType == null || theClass == null) && (CoreClassConstants.NUMBER.isAssignableFrom(value.getClass()))){
//if it's still a number and falls through the cracks we dont want "" around the value
BigDecimal convertedNumberValue = ((BigDecimal) ((ConversionManager) session.getDatasourcePlatform().getConversionManager()).convertObject(value, CoreClassConstants.BIGDECIMAL, schemaType));
jsonObjectBuilder.add(keyName, (BigDecimal)convertedNumberValue);
}else{
jsonObjectBuilder.add(keyName, convertedValue);
}
}
}