Search code examples
pythonjsontinydb

Is it possible to query nested json object using TinyDB


I have JSON file having following structure

{  
     "type":[  
        "apple-shimle",
        "king"
     ],

     "json-object":{  
        "test":"hi"
     }
  }

How to search for test == "hi" using TinyDB python only. Iam able to fetch "json-object" using search() but not "test".


Solution

  • As from the docs you can query nested fields like this:

    db.search(Check['json-object']['test'].exists())