public Object deserialize()

in sdk/core/azure-core-jackson/src/main/java/com/azure/android/core/serde/jackson/AdditionalPropertiesDeserializer.java [92:131]


    public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
        ObjectNode root = mapper.readTree(jp);
        ObjectNode copy = root.deepCopy();

        // compare top level fields and keep only missing fields
        final Class<?> tClass = this.defaultDeserializer.handledType();
        boolean isJsonFlatten = (tClass.getAnnotation(JsonFlatten.class) != null);
        for (Class<?> c : TypeUtil.getAllClasses(tClass)) {
            Field[] fields = c.getDeclaredFields();
            for (Field field : fields) {
                // JaCoCo adds synthetic fields for instrumentation.
                // It's recommended to skip fields that are marked synthetic.
                // https://www.eclemma.org/jacoco/trunk/doc/faq.html
                // https://github.com/jacoco/jacoco/issues/168
                if (field.isSynthetic()) {
                    continue;
                }
                String value = null;
                JsonProperty jProperty = field.getAnnotation(JsonProperty.class);
                if (jProperty != null) {
                    value = jProperty.value();
                }
                if (value != null) {
                    String key1 = isJsonFlatten ? JSON_FLATTEN_SPLIT.split(jProperty.value())[0] : jProperty.value();
                    if (!key1.isEmpty()) {
                        if (copy.has(key1)) {
                            copy.remove(key1);
                        }
                    }
                }
            }
        }

        // put into additional properties
        root.put("additionalProperties", copy);

        JsonParser parser = new JsonFactory().createParser(root.toString());
        parser.nextToken();
        return defaultDeserializer.deserialize(parser, ctxt);
    }