Some of the problems encountered in my work before, let’s briefly share these situations, not to mention more, directly to the problem.
1. Problem background
The json format data is shown in the figure below, b is an object array, which contains four objects. Now you need to parse out the spid in each array. Generally speaking, the number of objects contained in the array is 0-n, which is an uncertain There are 4 in the example in Figure 2 below.
Figure one
Figure II
2. Implementation ideas
1. Use the get_json_object() function
2. Cooperate with regular analysis to achieve any number of matches
3. Code implementation
select imp_date,
get_json_object(your_column,'$.a.b[*].c1.spid')as spids
from tmp where imp_date = %(date)s;
4. Summary
The overall idea is to use regular functions to obtain values based on keywords. If there are other better implementation methods, please feel free to express your ideas in the comments section below!