Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.jayway.jsonpath.spi.json.JsonProvider;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.util.Utf8;

import java.io.InputStream;
import java.util.ArrayList;
Expand Down Expand Up @@ -135,13 +136,20 @@ public void setArrayIndex(final Object o, final int i, final Object o1)
}
}

private Object transformAvroMapKey(String keyToTransform, Map avroMapObj) {
Object key = avroMapObj.keySet().iterator().next();
if (key instanceof Utf8) {
return new Utf8(keyToTransform);
}
return keyToTransform;
}
@Override
public Object getMapValue(final Object o, final String s)
{
if (o instanceof GenericRecord) {
return ((GenericRecord) o).get(s);
} else if (o instanceof Map) {
return ((Map) o).get(s);
return ((Map) o).get(transformAvroMapKey(s,(Map) o));
} else {
throw new UnsupportedOperationException(o.getClass().getName());
}
Expand Down