hive从0.12版本之后自带json序列化反序列化类,以前版本需要自己实现。
https://cwiki.apache.org/confluence/display/Hive/Json+SerDe
Json SerDe
Availability
The JsonSerDe for JSON files is available in Hive 0.12 and later.
Background
The JsonSerDe was moved to Hive from HCatalog and before it was in hive-contrib project. It was added to the Hive distribution by HIVE-4895.
Usage
To use the SerDe, specify the fully qualified class name org.apache.hive.hcatalog.data.JsonSerDe
, for example:
Depending on the distribution you might need to add hive-hcatalog-core.jar
:
For general information about SerDes, see Hive SerDe in the Developer Guide. Also see SerDe for details about input and output processing.