diff options
| author | jmoore <josh@glencoesoftware.com> | 2021-11-26 08:57:58 +0100 |
|---|---|---|
| committer | jmoore <josh@glencoesoftware.com> | 2021-11-26 08:57:58 +0100 |
| commit | 2bd4b7142da1a949843331d833e1bdec6d52d3ba (patch) | |
| tree | 172a9b77563419baa885eb811bf24bc72495c31e | |
| parent | 7ef44217bb3af6f3e046a47db8b1ae7d86406934 (diff) | |
| download | rdflib-2bd4b7142da1a949843331d833e1bdec6d52d3ba.tar.gz | |
Add a json example to docs
| -rw-r--r-- | rdflib/parser.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/rdflib/parser.py b/rdflib/parser.py index acbd1117..f7fb4127 100644 --- a/rdflib/parser.py +++ b/rdflib/parser.py @@ -106,8 +106,18 @@ class InputSource(xmlreader.InputSource, object): class PythonInputSource(InputSource): """ - Constructs an RDFLib Parser InputSource from a Python data structure - loaded from JSON with json.load or json.loads. + Constructs an RDFLib Parser InputSource from a Python data structure, + for example, loaded from JSON with json.load or json.loads: + + >>> import json + >>> as_string = \"\"\"{ + ... "@context" : {"ex" : "http://example.com/ns#"}, + ... "@graph": [{"@type": "ex:item", "@id": "#example"}] + ... }\"\"\" + >>> as_python = json.loads(as_string) + >>> source = create_input_source(data=as_python) + >>> isinstance(source, PythonInputSource) + True """ def __init__(self, data, system_id=None): |
