Class JSONPathParser
- java.lang.Object
-
- org.apache.druid.java.util.common.parsers.JSONPathParser
-
-
Constructor Summary
Constructors Constructor Description JSONPathParser(JSONPathSpec flattenSpec, com.fasterxml.jackson.databind.ObjectMapper mapper, boolean keepNullColumns)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getFieldNames()
Returns the fieldNames that we expect to see in parsed Maps, if known, or null otherwise.Map<String,Object>
parseToMap(String input)
Parse a String into a Map.void
setFieldNames(Iterable<String> fieldNames)
Set the fieldNames that you expect to see in parsed Maps.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.java.util.common.parsers.Parser
startFileFromBeginning
-
-
-
-
Constructor Detail
-
JSONPathParser
public JSONPathParser(JSONPathSpec flattenSpec, com.fasterxml.jackson.databind.ObjectMapper mapper, boolean keepNullColumns)
Constructor- Parameters:
flattenSpec
- Provide a path spec for flattening and field discovery.mapper
- Optionally provide an ObjectMapper, used by the parser for reading the input JSON.
-
-
Method Detail
-
getFieldNames
public List<String> getFieldNames()
Description copied from interface:Parser
Returns the fieldNames that we expect to see in parsed Maps, if known, or null otherwise. Deprecated; Parsers should not, in general, be expected to know what fields they will return.- Specified by:
getFieldNames
in interfaceParser<String,Object>
-
setFieldNames
public void setFieldNames(Iterable<String> fieldNames)
Description copied from interface:Parser
Set the fieldNames that you expect to see in parsed Maps. Deprecated; Parsers should not, in general, be expected to know what fields they will return. Some individual types of parsers do need to know (like a TSV parser) and those parsers have their own way of setting field names.- Specified by:
setFieldNames
in interfaceParser<String,Object>
-
parseToMap
public Map<String,Object> parseToMap(String input)
Description copied from interface:Parser
Parse a String into a Map. The result can be null which means the given input string will be ignored.- Specified by:
parseToMap
in interfaceParser<String,Object>
- Parameters:
input
- JSON string. The root must be a JSON object, not an array. e.g., {"valid": "true"} and {"valid":[1,2,3]} are supported but [{"invalid": "true"}] and [1,2,3] are not.- Returns:
- A map of field names and values
-
-