No project description provided
Project description
pydantic-jsonld
pydantic-jsonld is a light-weight Python package that aims to make use of
pydantic
for JSON-LD data.
What this is not: This package offers no functionality for compaction or expansion. Neither does it parse any given context.
Installation
pip install pydantic-jsonld
Documentation
Structure
This package offers two BaseModel implementations derived from pydantic.
One for working with compacted JSON-LD data and one for expanded JSON-LD data.
Since there is no implementation of context parsing, the compacted model includes several limitations.
This is, however, a design choice as to avoid the necessity of fetching external contexts as well as the heavy computation that comes with validating JSON-LD data.
Usage
For the most basic usage, see the following example
from pydantic_jsonld.compact import BaseModel, Value
# Define a model
class MyModel(BaseModel):
height: Value[float]
length: Value[float]
# Build an instance from JSON-LD data
data = {
"@context": {"@vocab": "http://www.example.org/"},
"height": 20.0,
"length": 10.0,
}
model = MyModel.model_validate(data)
# Access via model properties
assert model.height.value == 20.0
assert model.length.value == 10.0
# Recover the original data
dumped = model.model_dump(by_alias=True, exclude_none=True)
assert dumped == data
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_jsonld-0.1.0.tar.gz.
File metadata
- Download URL: pydantic_jsonld-0.1.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcb029a8ef03d4d76147de2a34a37b22abe35b46bc6ab25c486b937da70b61e7
|
|
| MD5 |
060d46f780a4a331d55e362aadfc5ed6
|
|
| BLAKE2b-256 |
b49278725c4c5e91f8843c0ba5a90364e90d3129788339099b060716e2fdaa8f
|
Provenance
The following attestation bundles were made for pydantic_jsonld-0.1.0.tar.gz:
Publisher:
publish.yml on Moritz72/pydantic-jsonld
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_jsonld-0.1.0.tar.gz -
Subject digest:
dcb029a8ef03d4d76147de2a34a37b22abe35b46bc6ab25c486b937da70b61e7 - Sigstore transparency entry: 1614729551
- Sigstore integration time:
-
Permalink:
Moritz72/pydantic-jsonld@bb1c50d7cd800afb873372c13d6d30741912454f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Moritz72
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bb1c50d7cd800afb873372c13d6d30741912454f -
Trigger Event:
release
-
Statement type:
File details
Details for the file pydantic_jsonld-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_jsonld-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
578c6af0662e0f3532bb04f0ca8416c6a83bf5bc7f6aaed7da61263c55930d92
|
|
| MD5 |
67ac762f75b996ad80f853634612b970
|
|
| BLAKE2b-256 |
738f80c7b04321644a2e8b8291da9e673eb7284b3829c3f726e976d2cfa04f14
|
Provenance
The following attestation bundles were made for pydantic_jsonld-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Moritz72/pydantic-jsonld
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_jsonld-0.1.0-py3-none-any.whl -
Subject digest:
578c6af0662e0f3532bb04f0ca8416c6a83bf5bc7f6aaed7da61263c55930d92 - Sigstore transparency entry: 1614729588
- Sigstore integration time:
-
Permalink:
Moritz72/pydantic-jsonld@bb1c50d7cd800afb873372c13d6d30741912454f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Moritz72
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bb1c50d7cd800afb873372c13d6d30741912454f -
Trigger Event:
release
-
Statement type: