Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Brief introduction of json string and its example usage

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "json string introduction and example usage", the content of the explanation is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "json string introduction and example usage" bar!

Brief introduction:

Get_json_object (string json_string, string path)

Description:

The first parameter is filled in the json object variable

The second parameter uses $for the json variable identification, and then uses. Or [] reads the object or array, or returns NULL if the json string entered is invalid.

Only one data item can be returned at a time.

For example:

Data is a field in the test table. The data structure is as follows:

Data = {"store": {"fruit": [{"weight": 8, "type": "apple"}, {"weight": 9, "type": "pear"}], "bicycle": {"price": 19.95," color ":" red "}}," email ":" amy@only_for_json_udf_test.net "," owner ":" amy "}

1.get single layer value

Hive > select get_json_object (data,'$.owner') from test; result: amy

2.get multi-layer value.

Hive > select get_json_object (data,'$.store.bicycle.price') from test; result: 19.95

3.get array values []

Hive > select get_json_object (data,'$.store.stores [0]') from test; result: {"weight": 8, "type": "apple"} explode

Explode is to split a complex array or map structure in a hive line into multiple lines.

Demo:

Select ordernumber, get_json_object (concat ('{', deviceId,'}'),'$.deviceInfo.deviceId') from table lateral view explode (split (substr (get_json_object (message,'$.data.YN031.results'), 3 get_json_object (message,'$.data.YN031.results')-4),'\},\) b1 as deviceId where Thank you for reading, the above is the content of "introduction to json string and example usage". After the study of this article, I believe you have a deeper understanding of the introduction of json string and example usage, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report