TransWikia.com

how get particular JSON block find by value from main JSON Object using json in python3

Stack Overflow Asked by Thribhuwan on December 11, 2021

I have find particular JSON block find by Value from main JSON below is the json

mainJSON = [{ "name":"John", "car":"Scorpio" },{ "name":"John", "car":"Maruti800" },{ "name":"Priya", "car":"BMW" },{ "name":"Nick", "car":"Audi" }, { "name":"Nick", "car":"Bentley" }]

search all json block find by name "Jonh"

like below OUTPUT

{ "name":"John", "car":"Scorpio" }
{ "name":"John", "car":"Maruti800" }
import json

data = json.load(mainJSON)

Please help me here to find block in quickly

One Answer

[x for x in mainJSON if x.get('name') == 'John']

Answered by CPak on December 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP