My rough attempt without testing, using pattern matching
match reply:
case [{"description": {"criteria": str() as criteria, "value“: str() as value}]:
print(criteria, value)
That will get you the first criteria and value if you have a list holding a dictionary with key description whose value is a dict with keys criteria and value whose values are str…I think
A better way might be
for entry in reply:
match entry:
case {"description": {"criteria": str() as criteria, "value": str() as value}:
print(criteria, value)
I am pretty new to match-case so I was curious which exact form works. Here is the code by @Melendowski made into runnable code (it is not necessary to use the keyword as):
That is the correct behaviour. The number of list items in the case pattern must match the number of list items in the data. Demonstration:
test_lists = (
['Crusoe'],
['Holmes', 'Watson'],
)
for test_list in test_lists:
print(f'--- testing {test_list}, all matches:')
match test_list:
case [a]:
print(f'One item list match: {a!r}')
match test_list:
case [a, b]:
print(f'Two items list match: {a!r}, {b!r}')
print()
--- testing ['Crusoe'], all matches:
One item list match: 'Crusoe'
--- testing ['Holmes', 'Watson'], all matches:
Two items list match: 'Holmes', 'Watson'
So, as John suggested and provided example: iterate the list.
Extract it from your data:
...
case [{"description": list(descriptions_list)}]:
...
…and iterate it using for. In the loop use another match statement to extract the data from the individual items.