Hi Team,

In geode, we are using our own written  parsing method in geode.
Method :
public static <T> T jsonToObject(String jsonString, Class<T> klass) {

it have custom parsing logic
   while (keys.hasNext()) {
        String key = keys.next();
        Method method = methodsMap.get("set" + capitalize(key));
        if (method != null) {
          Class<?>[] parameterTypes = method.getParameterTypes();
          if (parameterTypes.length == 1) {
            Class<?> parameterType = parameterTypes[0];

            Object value = jsonObject.get(key);
            if (isPrimitiveOrWrapper(parameterType)) {
              value = 
ConvertUtils.convert(getPrimitiveOrWrapperValue(parameterType, 
value),parameterType);
            }
            // Bug #51175
            else if (isArray(parameterType)) {
              value = toArray(value, parameterType);
            } else if (isList(parameterType)) {
              value = toList(value, parameterType);
            } else if (isMap(parameterType)) {
              value = toMap(value, parameterType);
            } else if (isSet(parameterType)) {
              value = toSet(value, parameterType);
            } else {
              value = jsonToObject(value.toString(), parameterType);
            }
            method.invoke(objectFromJson, new Object[] {value});
            noOfFields--;
          }

can we use replace this parsing with readValue method of ObjectMapper Class 
call?.

jackson-databind-2.8.6.jar
com.fasterxml.jackson.databind. ObjectMapper class
which have readValue method which works for all data type. It convert json to 
class type object.
What do you think??

Example :
             ObjectMapper mapper = new ObjectMapper();
             String emp_key = mapper.writeValueAsString(key1);
              System.out.println(emp_key);
             Object empkey = mapper.readValue(emp_key, SICKey1.class);


I have seen issue in this method

When key class having the byte[] inside it or method isArray, isList, isMap, 
toMap, toSet when these have byte[] inside it.

Any suggestion to adopt new method.

Thanks,
Dinesh Akhand
This message and the information contained herein is proprietary and 
confidential and subject to the Amdocs policy statement,

you may review at https://www.amdocs.com/about/email-disclaimer 
<https://www.amdocs.com/about/email-disclaimer>

Reply via email to