How can I only get the lines which do not have "popup:"
in them?
json_data = json.loads(raw_json, strict=False)
This is the data:
{
"259655": { "params": ["OIL", "9,5"], "availability": "1", "reload": ""},
"259656": { "params": ["OIL", "10"], "availability": "1", "reload": ""},
"259659": { "params": ["OIL", "11,5"], "availability": "1", "reload": ""} ,
"259661": { "params": ["SALT", "5"], "availability": "1", "reload": "", "popup": "" },
"259662": { "params": ["SALT", "5,5"], "availability": "1", "reload": "", "popup": "" },
"259663": { "params": ["SALT", "6"], "availability": "1", "reload": "", "popup": "" },
}
Here's a simple solution using dict comprehension to create a new dict without values that contain "popup" keys
filtered_dict = {i: json_data[i] for i in json_data if "popup" not in json_data[i]}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.