use of org.apache.servicecomb.codec.protobuf.codec.AbstractFieldCodec.ReaderHelpData in project incubator-servicecomb-java-chassis by apache.
the class TestParamDeserializer method testUpdateResult.
@Test
public void testUpdateResult() {
String[] stringArray = new String[1];
stringArray[0] = "abc";
Object[] object = new Object[1];
Object paramObject = paramDeserializer.updateResult(object, stringArray, new ReaderHelpData());
Assert.assertNotNull(paramObject);
Assert.assertEquals(paramObject, object);
}
use of org.apache.servicecomb.codec.protobuf.codec.AbstractFieldCodec.ReaderHelpData in project incubator-servicecomb-java-chassis by apache.
the class AbstractDeserializer method deserialize.
@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
Object result = createResult();
for (String fieldName = p.nextFieldName(); fieldName != null; fieldName = p.nextFieldName()) {
// p实际是ProtobufParser,其内部是可以直接取到proto field的,理论上可以根据id来索引
// 可是field默认没暴露出来,所以,直接用name索引了
ReaderHelpData helpData = readerHelpDataMap.get(fieldName);
if (helpData == null) {
continue;
}
JsonToken t = p.nextToken();
// Note: must handle null explicitly here; value deserializers won't
Object value = null;
if (t == JsonToken.VALUE_NULL) {
value = helpData.getDeser().getNullValue(ctxt);
} else {
value = helpData.getDeser().deserialize(p, ctxt);
}
result = updateResult(result, value, helpData);
}
return result;
}
Aggregations