![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
JSONLite is a lightweight, local JSON database for simple data storage.
pip install jsonlite
{
"data": [
{ "_id": 1,
"name": "Alice",
"age": 30
},
{ "_id": 2,
"name": "Bob",
"age": 25
},
{ "_id": 3,
"name": "Charlie",
"age": 20
}
]
}
You can use JSONlite directly to perform CRUD operations.
>>> from jsonlite import JSONlite
>>> # Initialize the database
>>> db = JSONlite('mydatabase.json')
>>> # Inserting one document
>>> result = db.insert_one({"name": "John Doe", "age": 30})
>>> result.inserted_id
1
>>> # Inserting multiple documents
>>> result = db.insert_many([
... {"name": "Jane Doe", "age": 25},
... {"name": "Alice", "age": 28}
... ])
>>> result.inserted_ids
[2, 3]
>>> # Finding one document
>>> document = db.find_one({"name": "John Doe"})
>>> document
{'_id': 1, 'name': 'John Doe', 'age': 30}
>>> # Finding multiple documents
>>> documents = db.find({"age": {"$gte": 25}})
>>> documents
[
{'_id': 1, 'name': 'John Doe', 'age': 30},
{'_id': 2, 'name': 'Jane Doe', 'age': 25},
{'_id': 3, 'name': 'Alice', 'age': 28}
]
>>> # Updating one document
>>> result = db.update_one({"name": "John Doe"}, {"$set": {"age": 31}})
>>> result.matched_count, result.modified_count
(1, 1)
>>> # Updating multiple documents
>>> result = db.update_many({"age": {"$gte": 25}}, {"$set": {"status": "active"}})
>>> result.matched_count, result.modified_count
(3, 3)
>>> # Deleting one document
>>> result = db.delete_one({"name": "John Doe"})
>>> result.deleted_count
1
>>> # Deleting multiple documents
>>> result = db.delete_many({"age": {"$lt": 30}})
>>> result.deleted_count
2
Alternatively, you can patch pymongo to use JSONlite and interact with JSON files as if you were using MongoDB. This allows you to use the familiar pymongo API with JSON data.
>>> from jsonlite import pymongo_patch
>>> pymongo_patch()
>>> from pymongo import MongoClient
>>> client = MongoClient('jsonlite://database')
>>> db = client.test_database
>>> collection = db.test_collection
>>> insert_result = collection.insert_one({"name": "Alice", "age": 30})
>>> # Just like using pymongo
>>> collection.drop()
JSONLite is licensed under the MIT License. See the LICENSE file for more information.
FAQs
A lightweight local JSON database
We found that jsonlite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.