I have a string as follows:
{
"getYearsListOverview": {
"sp_name": "analytics.year_overview_drop_down",
"sp_input_params": {
"req_url_query_params": [],
"req_body_params": []
},
"sp_output_datasets": [],
"page_name": "home"
},
"getRankingsDataPerformanceReport": {
"sp_name": "analytics.get_performance_ranking_data",
"sp_input_params": {
"req_url_query_params": [
["@scroll_index", "index"]
],
"req_body_params": [
["@event_type_id", "event_type_id"],
["@season", "season"],
["@athlete_guid", "athlete_guid"]
]
},
"sp_output_datasets": [],
"number_of_output_datasets_for_customized_template": 4,
"customised_response_template": {
"performance_value_list": [],
"rankings_table": [],
"level_values": []
},
"page_name": "performancereport"
}
}
I want to read the strings after sp_name, req_url_query_params,req_body_params and finally page_name fields and put them inside a list.
E.g.
sp_name = ['analytics.year_overview_drop_down','analytics.get_performance_ranking_data']
req_url_query_params = ['','@scroll_index, index']
req_body_params = ['','@event_type_id, "event_type_id,@season,season,@athlete_guid,athlete_guid']
It seems I have to use regex
and then re.findall()
. But I am not quite proficient in the same. Glad if someone can share the search string.
Pseudo Code:
s = re.findall(r'sp_name(\w+)*',original_string)
Will the above code work?