There are two ways to load json file formats into hive.
1.
create table json_guru(str string);
load data inpath 'home/hduser/test.json' into table json_guru;
select * from json1;
select get_json_object(str,'$.ecode') as ecode, get_json_object(str,'$.ename') as ename ,get_json_object(str,'$.sal') as salary from json_guru;
where the json data somewhat looks like this.
![image](https://attachment.freshdesk.com/inline/attachment?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDA1NjA3MDUzMiwiZG9tYWluIjoiZWR1cmVrYS5mcmVzaGRlc2suY29tIiwiYWNjb3VudF9pZCI6NDE0NTN9.1Bol_fS6bb6K0iWog2F2qxEFjASPW9IHdb8ZsH41610)
2.
The second way is to use hive json serde jar to do the same . Please have a look below for your reference.
CREATE TABLE my_table (field1 string, field2 int,
field3 string, field4 double)
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.JsonSerde' ;
Add the Jar :- ADD JAR /path-to/hive-json-serde.jar;
load the file :- load data inpath 'folder/to/json/data.json' into my_table;