Saravanan666/pypi-org huggingface dataset:
Package: jsondict
Dict with json file saving / restoring supportdatetime, date supportreadable formated jsonsafely file write with file move os functionauto-save supportcompression supportInstallpip install jsondictUsage>>> from datetime import datetime
>>> from jsondict import JsonDict
>>> db = JsonDict('var/test.json')
>>> db.clear()
>>> db.update({'b': 2, 'created': datetime(2013, 1, 27, 21, 14), 'a': 1})
>>> db.save()
>>> open(db.filename).read()
'{\n  "a": 1,\n  "b": 2,\n  "created": "2013-01-27T21:14:00Z"\n}'Auto-save and compression>>> import gzip
>>> db = JsonDict('var/test.json.gz', compress=True, autosave=True)
>>> db.clear()
>>> db['x'] = 'y'
>>> gzip.open(db.filename).read()
'{\n  "x": "y"\n}'
Package: json-dict-transformer
json-dict-transformerThis package helps transform an input JSON (as Pythondict) into another
JSON (alsodict) using provided schema.The main goal behind this package was to enable proxying requests between
two systems. The first returns JSON data, which can be transformed and sent
to the second system.Transforming is understood as changing the structure of JSON data.
For example, splitting some fields or concatenating fields into other fields.
In other words, it is a process of reformatting JSON data preserving values
but changing the structure.ExampleTake a look atexamples/example-1.pyOutput:{
  'full name': 'John Doe',
  'age': '30',
  'address': 'Main Street,123,New York,USA',
  'hobbies': 'MY HOBBIES ARE: football,basketball,tennis'
}InstallationInstall the package using PIP:pipinstalljson_dict_transformer# orpipinstallgit+https://github.com/thevops/json-dict-transformer.git@masterUsageInput data formatThe package needs data in Pythondictformat. You can convert JSON intodictusing the following code:importjsonwithopen('data.json')asjson_file:data=json.load(json_file)print(type(data))# it should return type `dict`SelectorsThe schema for mapping uses selectors to point to specific fields.
For now, there are only 2 available selectors.json::<field path>The selector extracts data from a field. A path is built using dot
notation. Please, take a look at the above example.txt::<string>The selector adds a string. It can be used to add a splitter or
any other text to the output data.<function>(Callable object)Allows to use a function over the data on the left side of that function.
A function can be passed from outside.
Requires to handle a single argument of type string.Similar projectshttps://github.com/Onyo/jsonbenderhttps://github.com/ebi-ait/json-converterChangelog1.0.0The first version1.1.0Add support for functions for processing data during transformation1.1.1Fix functions feature
Package: json-diff
Compares two JSON files (http://json.org) and generates a new JSON file
with the result. Allows exclusion of some keys from the comparison, or
in other way to include only some keys.The project’s website is athttps://gitlab.com/mcepl/json_diffPatches and pull requests are welcome, but please keep the script compatible
with python 2.4.Released under MIT/X11 license.Changelog:1.5.0 2019-08-25Port to Python 3 (most tests pass, one skipped)1.4.3 2019-08-06Fix tests to work.1.4.2 2019-08-06Allow running main() without formal arguments.1.4.1 2018-07-21Fix tests1.4.0 2018-07-21Generate proper script with entry_points.1.3.7 2018-07-20New email address of the maintainerSkip failing test1.3.5 2017-01-13Fedorahosted dies, everything (including submodules) moved to
GitLab.com1.3.4 2015-03-13Switch to setuptoolsReorganization of repositories (fedorahosted)1.3.3 2012-04-24Grrr, python 2.4 doesn’t have context managers1.3.2 2012-04-24Include mising test/__init__.py to the distribution to allow
tests for packgaging.1.3.1 2012-04-23Back to the past: previous version was not compatible with Python 2.4.1.3.0 2012-04-23Added -o parameter for output to the specified file.1.2.9 2012-02-13Give up on non-UTF-8 encoding for output.1.2.7 2012-01-18Yet another (hopefully the last) fix of the development website. We are on fedorahosted.org now.1.2.6 2012-01-18Move tests to test/ moduleClean up setup.py (when using defaults, install doesn’t install tests,
which I like)Add new setup.py command test to run the test suite.1.2.5 2012-01-11Switch the project’s website and clean up UTF-8 metadata.1.2.1 2011-12-03Change of the home URL to my trac.1.2.0 2011-12-01One more python 2.4 compatibility fix.Maintainer of optparse library couldn’t have a better idea than to change
“usage:” to “Usage:” (between 2.4 and 2.6)! Grrrrrrr.1.2.0 2011-12-01Fix locale.setlocale to work on RHEL 5.1.2.0 2011-11-30Make tests working independently of the locale set on the system.1.2.0 2011-11-30Set exit status of json_diff command.0 means no difference
1 there is a difference.Now actually works correctly with non-mandatory options.1.1.0 2011-11-29Make scripts pylint and PEP8 compliant.Add option -a to ignore appended keys (for comparing changing piglit tests).Fix formatted output to stdout (or file).Added test for -i functionality.0.9.2 2011-11-21Python 2.4 compatible0.9.1 2011-11-21Two small nits in __main__ part.(for detailed log of all changes see git log)
Package: json-digger
# Python dictionary/JSON digger# AboutThe script is to help you look either for specific keys or values in multi-tier nested python dictionaries (either native or converted from JSON).# UsageI am using it heavily in analyzing the data retrieved from REST APIs (Google, Bing, Linkedin etc.), NoSQL dbs (MongoDB etc.), python dictionaries.# Installation```$ pip install json-digger```# Python VersionIt has been developed and tested under Python 2.7. However it supports also Python 3.# How to use?```pythonfrom json_digger.json_digger import JsonDiggerweather = {"coord":{"lon":-0.13,"lat":51.51},"sys":{"type":3,"id":60992,"message":0.0921,"country":"GB","sunrise":1423639268,"sunset":1423674497},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"base":"cmc stations","main":{"temp":278.05,"humidity":84,"pressure":1025.6,"temp_min":278.05,"temp_max":278.05},"wind":{"speed":2.39,"deg":122.505},"rain":{"3h":0},"clouds":{"all":80},"dt":1423646999,"id":2643743,"name":"London","cod":200}i = JsonDigger(weather) #  initialize class instancer_k = i.get_keys('country') #  search for key 'country'r_v = i.get_values(278.05) #  search for value '278.05'print r_k #  response: {u':sys:country': [u'GB']}print r_v #  response: {u':main:temp': [278.05], u':main:temp_max': [278.05], u':main:temp_min': [278.05]}```More in tester.py!# Must have (if work with JSONs)JSON module for Python (https://docs.python.org/2/library/json.html).# Release History0.2.0 (2016-02-20)Added support for Python 3.0.1.0 (2015-02-11)First release.
Package: jsondler
jsondlerJSON handler for PythonInstallationTo install the package from PyPI type:pip install jsondlerOr from the repo:pip install git+https://github.com/loven-doo/jsondler.gitFor 'dev' branch version:pip install git+https://github.com/loven-doo/jsondler.git@devPackage referenceDictsListjson_tools
Package: json-doc
python-json-docUtility functions for JSON DocumentIt can handle get/set/pop/has operations on nodesExtendedsetfunctions for lists:append: appends to the listextend: extends the listreplace:searchand replace in the listreplace_re:searchand replace in the list using regular expressionNo external dependencies. Tests requiresunittest2moduleCompatible with Python 2.6+ and 3.3+Examplesdoc={'a':{'deep':{'nested':{'list':[1,2,3,{'dict':'OK'}],'string':'string','hex':0x010101}},},'list':[1,2,3]}# getprintjson_doc_get(doc,'/a/deep/nested/list/3/dict')>>OK# setprintjson_doc_set(doc,'/a/deep/nested/string','new string')['a']['deep']['nested']['string']>>newstring# pop: target existprintjson_doc_pop(doc,'/a/deep/nested/list/2')>>True# pop: target doesn't existprintjson_doc_pop(doc,'/a/deep/nested/list/5')>>False# has itemprintjson_doc_has(doc,'/a/deep/nested/list/3/dict')>>True# has item with valueprintjson_doc_has(doc,'/a/deep/nested/list/3/dict','OK')>>True## List only functions# appendprintjson_doc_append(doc,'/list',4)['list'][1,2,3,4]# extendprintjson_doc_extend(doc,'/list',[5,6,7])['list'][1,2,3,4,5,6,7]# replace: value -> new value, search -> old valueprintjson_doc_replace(doc,'/list',44,4)['list'][1,2,3,44,5,6,7]# replace_re: -> new value, search -> regex[111,2,3,44,5,6,7]
Package: jsondt
JSON with datetime support.This module is a light shim around the existing standard library JSON moduile.It encodes and decodes Python datetime objects as human-readable ISO8601 dates.It is a drop-in replacement for standard library JSON, so you can just do:>>> import jsondt as jsonThen carry on with the standard library JSON documentation.Currently, this module supports only Python 3.7 and above.Backporting to older versions is possible if there is demand for it.Simple exampleHere we go:>>> import jsondt as json
>>> from datetime import datetime
>>> myobject = {'ctime': datetime.now()}
>>> encoded = json.dumps(myobject)
>>> print(encoded)
'{"ctime": "2019-08-19T18:18:25.609815"}'
>>> decoded = json.loads(encoded)
>>> print(decoded)
{'ctime': datetime.datetime(2019, 8, 19, 18, 18, 25, 609815)}
>>> myobject == decoded
TrueJavaScript compatibleOne of the main use cases is to interoperate with JSON produced by
JavaScript in the browser.Spin up your Javascript console:>>> const record = {'ctime': new Date()}
>>> const encoded = JSON.stringify(record);
>>> console.log(encoded)
{"ctime":"2019-08-19T17:25:03.547Z"}Now get that JSON string to Python through your API call or post request
(here’s one that we made earlier):>>> encoded = '{"ctime":"2019-08-19T17:25:03.547Z"}'
>>> import jsondt as json
>>> json.loads(encoded)
{'ctime': datetime.datetime(2019, 8, 19, 17, 25, 3, 547000,
tzinfo=datetime.timezone.utc)}Say HelloI am interested in more common use cases for ISO 8601 dates.If you have an ISO 8601 date in JSON produced by a well known application
or library (in any language) and jsondt does not recognise it, please make
an issue on GitHub and I will see if I can add support.Control ModeYou probably don’t need to care about this bit.There is a second mode that is semi-automatic instead of fully-automatic.Imagine we have this strange object:>>> strange = {'a_date': datetime.datetime(2019, 8, 19, 21, 32, 59, 169730),
...            'b_date': '2018-05-01T07:03:44.560600'}If we dump it and load it back, it will load both dates as datetime objects.>>> import jsondt as json
>>> encoded = json.dumps(strange)
>>> decoded = json.loads(encoded)
>>> decoded == strange
FalseIf however, you prefer the original object back, you can use control mode.>>> import jsondt as json
>>> encoded = json.dumps(strange, control=True)
>>> decoded = json.loads(encoded, control=True)
>>> decoded == strange
TrueThe way it works, is that with control=True, it puts a control code
(backslash D) at the start of the encoded date. Like so:>>> print(encoded)
{"a_date": "\\D2019-08-19T21:32:59.169730",
 "b_date": "2018-05-01T07:03:44.560600"}Thanks for readingIf you want more examples, read the supplied tests.
Package: json-dunder
Encdoe objects with a __json__ dunder method and decode objects with a __from_json__ dunder method.importjson_dunder# Use tells json to use this classcoder=json_dunder.JsonDunderTypeCoder().use()@coder.registerclassA:def__init__(self,x):self.x=xdef__eq__(self,other):ifisinstance(other,self.__class__):returnself.x==other.xreturnFalsedef__json__(self):return{"x":self.x}@classmethoddef__from_json__(cls,d:dict):returncls(**d)@coder.registerclassB:def__init__(self,a,y):self.a=aself.y=ydef__eq__(self,other):ifisinstance(other,self.__class__):returnself.a==other.aandself.y==other.yreturnFalsedef__json__(self):return{"a":self.a,"y":self.y}@classmethoddef__from_json__(cls,d:dict):returncls(**d)a=A(1)b=B(a,2)sa=json_dunder.dumps(a)assertsa=='{"x": 1, "__json_type__": "__main__.A"}'sb=json_dunder.dumps(b)assertsb=='{"a": {"x": 1, "__json_type__": "__main__.A"}, "y": 2, "__json_type__": "__main__.B"}'obj=json_dunder.loads(sa)assertobj==aobj=json_dunder.loads(sb)assertobj.a==aassertobj==bInstallpip install json_dunder
Package: jsoneditor
💥py-jsoneditor💥Quickly View and Edit any JSON data.Why?When working with JSON data, You often need to get a structured view of the JSON in order to be able to work with it. There's an online toolhttps://jsoneditoronline.org/which I used for this, but copying/pasting all the time got frustrating pretty quickly, This is why I created this package which you can launch right from Python or from the command line.ScreenshotInstallationpipinstalljsoneditorPython exampleIn python you can simply importjsoneditorand call theeditjsonfunction, the first argument is going to be the data. SeeFormats you can pass the JSON asfor all the formats you can pass the JSON in. SeePython apifor a full list of addtional arguments that you can pass toeditjson.importrequestsimportjsoneditordata=requests.get('https://jsonplaceholder.typicode.com/comments').json()jsoneditor.editjson(data)Command line exampleFrom the command line you can either pass the data as an argument as so:jsoneditor'{"Hey": "Hi"}'Or you can pipe it in like so:curlhttps://jsonplaceholder.typicode.com/comments|jsoneditorOr you can use what you have in your clipboard like so:jsoneditor-cSeeFormats you can pass the JSON asfor all the formats you can pass the JSON in.Refer toCLI optionsfor a list of all cli options. Alternatively you can runjsoneditor --helpfrom your terminal to see it.Formats you can pass the JSON asYou can pass the json in any of the following formats:as valid json string. Example:{"Hey": "Hi"}as a python dict. Example:{'Hey': 'hi'}as a url the points to valid json. Example:https://jsonplaceholder.typicode.com/commentsas a file path that is valid json. Example:data.jsonPython ApiparametertypeoptionaldescriptiondataAny❌The data in any oftheseformats.callbackcallable✔️If you provide this argument you will have a ✅ button which will trigger this callback.optionsdict✔️Options to pass the the jsoneditor object. Seehereadditional_jsstr✔️You can pass some JavaScript to run on the client side. You can interact with the editor by accessing thewindow.editorvariable.keep_runningbool✔️Whether to keep the server running. Defaults toFalse.run_in_threadbool✔️Whether to run the server in a separate thread. Defaults toFalse.is_csvbool✔️Whether the data is csv data. Defaults toFalse.is_yamlbool✔️Whether the data is yaml data. Defaults toFalse.is_ndjsonbool✔️Whether the data is Newline Delimited JSON  . Defaults toFalse.is_js_objectbool✔️Whether the data is a JavaScript Object. Defaults toFalse.titlestr✔️A title to display in the browser.portint✔️specify which port to use.CLI optionsparameterdescriptiondataThe data in any oftheseformats-oAdd a button that will output the json back to the console-bKeep running in background-cGet JSON input from clipboard-kKeep alive-eEdit mode-nDon't launch browser-pServer port--outFile to output when in edit mode-tTitle to display in browser window--csvInput is CSV--yamlInput is YAML--jsInput is a JavaScript Object--ndjsonInput is Newline Delimited JSONBuildpythonsetup.pysdistAcknowledgementsjsoneditor
Package: json-encoder
json encoder usessingledispatch patterninstead of JSONEncoder class overwrites.No morejson.dumps(data, cls=MyJSONEncoder)everywhere.Comes with default serialization for time, date, datetime, UUID and DecimalEasy to use, easy to change serialization behaviourNot tight to any json implementationjson, simplejson, ujson…It parse json float numbers into Decimal objects to prevent python float precision issues.Installation$pipinstalljson-encoderQuick startUse “json_encoder.json” instead of default python json:from json_encoder import json

result = json.dumps(data)ConfigurationChose json implementation:# simplejson library is used as default json implementation if present
# otherwise standard python json implementation is used
# to use other json implementation globally, do:

import ujson
from json_encoder import use_json_library

use_json_library(ujson)To change json implementation for concrete call do:from json_encoder import json
import simplejson

result = json.dumps(data, json=simplejson)To make your object JSON serializable do:# example how to make python fraction object json serializable

from fractions import Fraction
from json_encoder.encoder import json_encoder

@json_encoder.register(Fraction)
def encode_fraction(obj):
    return '{}/{}'.format(obj.numerator, obj.denominator)To overwrite JSON serializer behaviour defined in json_encoder.encoder:from uuid import UUID
from six import text_type
from json_encoder.encoder import json_encoder

@json_encoder.register(UUID)
def encode_uuid(obj):
    return text_type(obj).replace('-', '')Requirementssingledispatch>= 3.4.0.3 for python version < 3.4 only
Package: json-encrypted-token
jet-pythonJSON Encrypted Token - Python modulefromjetimportJETfromjet.utilsimporthmac_sha256GLOBAL_JET=JET(SECRET='my-secret-string')user_secret=hmac_sha256('user-password','user-password','ascii')payload={'id':1,'message':"Hola"}# Generate tokentoken=GLOBAL_JET.encrypt(user_secret,payload)# Get info on tokendecrypted_meta,decrypted_payload=GLOBAL_JET.decrypt(user_secret,token)# Get info on token without user_secretdecrypted_meta,decrypted_payload=GLOBAL_JET.decrypt_from_PK(token)# Verify tokenverified_sign=GLOBAL_JET.is_valid_token(token)print("Token is valid? ",verified_sign)# Refresh tokennew_token=GLOBAL_JET.refresh_token(token)print("Token == New Token ",token==new_token)
Package: jsonene
jsoneneThis library is intended to provide APIs to define JSON schema, create instances from schema, serialize/de-serialize to/from json or dict to Objects.Inspired byjsonschemajson-schemaThe basic idea is to provide light weight class based schema defination and data classesInstallationpip install jsoneneDemos:importenumfrompprintimportpprintimportjsoneneclassGender(enum.Enum):MALE="Male"FEMALE="Female"OTHER="Other"classPerson(jsonene.ObjectType):classMeta:field_dependencies=[jsonene.RequiredDependency("age",["date_of_birth"])]age=jsonene.Integer(required=False)name=jsonene.String()country=jsonene.Const("India")email=jsonene.Format(jsonene.Format.EMAIL)contact=jsonene.String(required=False)date_of_birth=jsonene.Format(jsonene.Format.DATE,required=False)gender=jsonene.Enum(Gender)ip=jsonene.Format(jsonene.Format.IPV4)classSeller(Person):brokerrage=jsonene.Integer(required=False)is_broker=jsonene.AnyOf(True,False)is_owner=jsonene.AnyOf(True,False)# Nested schemaclassHouse(jsonene.ObjectType):owner=jsonene.Field(Person)seller=jsonene.Field(Seller)# Know your json-schemapprint(Person.asField().json_schema)owner=Person(name="test",age=30,country="India",email="conikhil@gmail.com",gender=Gender.MALE.value,date_of_birth="1989-09-11",ip="10.8.9.0",)owner.validate(check_formats=True)
Package: jsoneng
JSON EngineThis is the lite version of the JSON Engineplease refer tohttps://pypi.org/project/jsoneng/for the python packageand please refer tohttps://github.com/youhengzhou/jsonengfor the repoDownload Packagepy -m pip install jsoneng -UIn Your Python Filesimport jsonengineCommandsCreate command:eng.create(dictionary, path)This will create a JSON dictionary in the pathRetrieve command:eng.retrieve(path)This will retrieve the JSON dictionary in the pathUpdate command:eng.update(dictionary, path)This will update a JSON dictionary in the pathUpdate in this case means replacing the dictionary in its entirety with a new oneUpdate (with key value) command:eng.update_kv(key, value, path)This will update a key value pair in the JSON dictionary in the pathUpdate in this case means replacing the dictionary with the key value pairPatch command:eng.patch(dictionary, path)This will patch a JSON dictionary in the pathPatch in this case means keeping the JSON dictionary in the path and appending to the dictionaryPatch (with key value) command:eng.patch_kv(dictionary, path)This will patch a key value pair in the JSON dictionary in the pathPatch in this case means keeping the dictionary and appending the new key value pairDelete command:eng.delete(path)This will delete the JSON dictionary in the path
Package: jsonengine
JSON Engineplease refer tohttps://pypi.org/project/jsonengine/for the python packageand please refer tohttps://github.com/youhengzhou/json-crud-enginefor the repoDownload Packagepy -m pip install jsonengine -UIn Your Python Filesimport jsonengineCommandsCreate command:eng.create(dictionary, path)This will create a JSON dictionary in the pathRetrieve command:eng.retrieve(path)This will retrieve the JSON dictionary in the pathUpdate command:eng.update(dictionary, path)This will update a JSON dictionary in the pathUpdate in this case means replacing the dictionary in its entirety with a new oneUpdate (with key value) command:eng.update_kv(key, value, path)This will update a key value pair in the JSON dictionary in the pathUpdate in this case means replacing the dictionary with the key value pairPatch command:eng.patch(dictionary, path)This will patch a JSON dictionary in the pathPatch in this case means keeping the JSON dictionary in the path and appending to the dictionaryPatch (with key value) command:eng.patch_kv(dictionary, path)This will patch a key value pair in the JSON dictionary in the pathPatch in this case means keeping the dictionary and appending the new key value pairDelete command:eng.delete(path)This will delete the JSON dictionary in the path
Package: json-enhanced
JSON EnhancedJSON Enhanced implements fast and pythonic queries and mutations for JSON objects.InstallationYou can install json-enhanced with pip:pip install json-enhancedQuickstartimportjsonutilsasjsfromdatetimeimportdatetime# We create a new JSONObject either directly or from a local file/URL:json_data=js.JSONObject({"data":[{"name":"Dan","birthday":"1991-01-02 09:00:00","publications":15},{"name":"Mar","birthday":"1991-03-02 12:30:00","publications":13},{"name":"Carl","birthday":"1950-06-02 16:00:00","publications":36},{"name":"Vic","birthday":"1986-07-02 16:00:00","publications":None},]})# Now we can navegate through this object by attribute accesion:json_data.data._1.name# 'Mar'# Or we can make queries. The syntax is very similar to Django's querysets:result=json_data.query(birthday__lt=datetime(1985,1,1))result# <QuerySet ['1950-06-02 16:00:00']>result.first().parent# {'name': 'Carl', 'birthday': '1950-06-02 16:00:00', 'publications': 36}# We can also retrieve the path of a node:result.first().jsonpath# data/2/DocumentationDetailed documentation is available atjson-enhanced.readthedocs.io.ContributingContributions are welcome! Please take a look at our contributors guide.Code of ConductPlease readCODE_OF_CONDUCT.mdfor details on our code of conduct.LicenseThis project is licensed under theGPL-3.0 License. For details, please read ourLICENSE FILE.