FullJSON
The package is for JSON conversion in Python enviroment.
| JSON Type | JSON Type Example | Python Type | Python Type Value |
|---|---|---|---|
| object | {} | dict | type({}) |
| array | [] | list | type([]) |
| string | "example" | str | type('example') |
| number | 1/1.0 | int/float | type(1)/type(1.0) |
| "true" | true | True | type(True) |
| "false" | false | False | type(False) |
| "null" | null | None | type(None) |
Implements
Convert a JSON string into a JSON object
JSON.parse(value) is based on stack structure.
There are three stacks in the program, stack stack for characters, class_stack stack for list and dict, keyvalue_stack stack for name/value pair.
Scan each character in the string, do the following:
- If is
[, put type/value intoclass_stackstack - If is
{, put type/value into theclass_stackstack, and put an empty key/value pair (namedborder) into thekeyvalue_stackstack - If is
,, according toclass_stackstack top type (list and dict),listis to operate on the top of theclass_stackstack and call its append method,dictis pushed into thekeyvalue_stackstack - If is
], popping all the elements on the top of thestackstack until it encounters[ - If is
}, pop thekeyvalue_stackstack and pop all the elements on the top of the stack until it encountersborder - If is
:, operate on the top of thekeyvalue_stackstack and modify the value in the key/value pair - Other, put characters into the
stackstack
Convert JSON values to JSON strings
JSON.stringify(value) is using recursive method.
- If it is a basic type in Python (number, string, bool, None), return the corresponding string (1/1.0, "example", true/false, null)
- If it is list and dict, repeat step 1 for each element in the list and dict
- Others, It is a class, consider as a dict type, terating over member variables of a class, do the same action as step 1
Installation
pip install fulljson
Examples
- Convert a JSON string into a JSON object.
>>> from fulljson import JSON
>>>
>>> value = '["foo", {"bar": ["baz", null, 1.0, 2, true]}]'
>>> print(JSON.parse(value))
['foo', {'bar': ['baz', None, 1.0, 2, True]}]
>>>
- Convert JSON values to JSON strings.
>>> from fulljson import JSON
>>>
>>> value = ["foo", {"bar": ["baz", None, 1.0, 2, True]}]
>>> print(JSON.stringify(value))
["foo",{"bar":["baz",null,1.0,2,true]}]
>>>
- Format JSON object or JSON strings
>>> from fulljson import JSON
>>>
>>> value = [{'foo': 'new 0', 'index': None}, "sat", {'bar': 'new 2', 'index': [1, True]}]
>>> print(JSON.format(value))
[
{
"foo":"new 0",
"index":null
},
"sat",
{
"bar":"new 2",
"index":[
1,
true
]
}
]
>>>
Metadata
Release files for fulljson 0.0.53
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fulljson-0.0.53.tar.gz | 6.1 kB | Without provenance | Details for fulljson-0.0.53.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fulljson-0.0.53-py3-none-any.whl | Python 3 | none | any | Details for fulljson-0.0.53-py3-none-any.whl |
Total release size: 14.6 kB
Release files / fulljson-0.0.53.tar.gz
| Download URL | fulljson-0.0.53.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d0582d654f49448c878f7436670dee3d220001c818ec6ab4cd988a87b251465
|
|
BLAKE2b-256 checksum How to use checksums |
9e80b570d3ae2b06c06ee38314c89f3c9df5016ce2e711bb9e21dc19d3ef7b70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.5.4
|
Release files / fulljson-0.0.53-py3-none-any.whl
| Download URL | fulljson-0.0.53-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7c10f354c2b3c07a223d4594ff76683187ea030daa9cedb85079a43ecbc471c
|
|
BLAKE2b-256 checksum How to use checksums |
86178756021bedb54f4f11028865a4120b96cb272c95d6fa09935a0ad99f904d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.5.4
|
Security for fulljson 0.0.53
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.