Saravanan666/pypi-org huggingface dataset:
Package: jsonseq
jsonseqRFC 7464 JSON Text Sequencesencoding and decoding for Python.UsageThejsonseq.encode.JSONSeqEncoderclass takes streams of JSON-serializable
Python objects and yields for each object its JSON representation sandwiched
between an optional ASCII record separator (RS,\x1e) and a newline (\n).>>>fromjsonseq.encodeimportJSONSeqEncoder>>>forchunkinJSONSeqEncoder().encode(({"a":i,"b":i}foriinrange(3))):...print(repr(chunk))...'{"a": 0, "b": 0}\n''{"a": 1, "b": 1}\n''{"a": 2, "b": 2}\n'The RS allows pretty-printed JSON to be streamed out in sequences that can be
decoded again.>>>forchunkinJSONSeqEncoder(with_rs=True,indent=2).encode(({"a":i,"b":i}foriinrange(3))):...print(repr(chunk))...'\x1e{\n"a": 0,\n"b": 0\n}\n''\x1e{\n"a": 1,\n"b": 1\n}\n''\x1e{\n"a": 2,\n"b": 2\n}\n'You can also get small chunks of the JSON sequences as they are encoded with
theiterencode()method.>>>forchunkinJSONSeqEncoder(with_rs=True).iterencode(({"a":i}foriinrange(3))):...print(repr(chunk))...'\x1e''{''"a"'': ''0''}''\n''\x1e''{''"a"'': ''1''}''\n''\x1e''{''"a"'': ''2''}''\n'You can use eitherencode()oriterencode()to copy JSON text sequences to a file.withopen("/tmp/example.jsons","w")asf:forchunkinJSONSeqEncoder(with_rs=True,indent=2).iterencode(({"a":i,"b":i}foriinrange(3))):f.write(chunk)There is no need to add a newline when calling the file'swrite()method.
JSONSeqEncoder ensures that it's already there where it needs to be.Thejsonseq.decode.JSONSeqDecoderclass takes streams of JSON texts
sandwiched between the optional ASCII record separator (RS,\x1e) and
a newline (\n) and yields decoded Python objects.>>>stream=['\x1e','{','"a"',': ','0','}','\n','\x1e','{','"a"',': ','1','}','\n','\x1e','{','"a"',': ','2','}','\n']>>>forobjinJSONSeqDecoder().decode(stream):...print(repr(obj))...{'a':0}{'a':1}{'a':2}Objects can be read from a file in the same way.>>>withopen("/tmp/example.jsons")asf:...forobjinJSONSeqDecoder().decode(f):...print(repr(obj))...{'a':0,'b':0}{'a':1,'b':1}{'a':2,'b':2}
Package: json-serde
json-serdeJSON de/serializer for Python, inspired byattrsandSQLAlchemy.Exampleimportrequestsfromjson_serdeimportJsonSerde,Integer,String,IsoDateTimeclassUser(JsonSerde):username=String()user_id=Integer(rename='userId')birthday=IsoDateTime(is_optional=True,default=None)resp=requests.get('https://example.com/api/user')resp.raise_for_status()api_response=resp.json()# {'username': 'emmag', 'userId': 1312, 'somethingElse': ['irrelevant']}user=User.from_json(api_response)assertuser.username=='emmag'assertisinstance(user.user_id,int)assertuser.birthdayisNoneLicenseThis work is dual licensed under the MIT and Apache-2.0 licenses. SeeLICENSE-MITandLICENSE-APACHEfor details.
Package: json-serializer
Package json_serializerThe library for serialize/deserialize into format JSON.How use it?For example you have class that needed serialize or deserialize.classCar(object):mark=Nonemodel=Noneyear=Nonecolor=NoneCreate objectcar=Car()car.mark='Ford'car.model='Mustang'car.year=2016car.color='Black'Import class JsonSerializer and create object of serializerIn the constructor pass list of classes that will be involved in serialization/deserialization.fromjson_serializer.SerializerimportSerializer...serializer=Serializer([Car])Serializationstring=serializer.serialize(car)# sting contains next json:# {#    "mark": "Ford",#    "model": "Mustang",#    "year": 2016,#    "color": "Black"# }Deserializationcar=serializer.deserialize(string)Variablecartype ofCarand contains values of all fields.Enjoy!
Package: json-server
JSON ServerAn tiny CLI to load data from a JSON File during development.After installingjson-serverbypip install json_serverYou can runjson_server <path-to-JSON-file> <port:optional>The port argument defaults to5000This shall output:* Serving Flask app 'json_server.main' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 816-527-262
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)Which is similar to what a standard Flask app logs.Now that you have run the command,http://127.0.0.1:<port>/shall respond with your JSON.
Package: json-server-py
json-server.pyFake REST API with zero coding.This project is heavily inspired byjson-serverin JavaScript.Requires Python 3.6+.InstallationIt's highly recommended to install withpipx.$pipxinstalljson-server.pyOr install with pip at your own risk:$pip3installjson-server.pyGet StartedCreate adb.jsonfile with following content:{"posts":[]}Start a server:$json-serverdb.jsonCreate a post:$curl-H'content-type: application/json'-d'{"content":"blablabla"}'http://localhost:3000/postsList all posts:$curlhttp://localhost:3000/postsUsageUsage: json-server [OPTIONS] [FILENAME]

  Start a JSON server.

  FILENAME refers to the JSON file where your data is stored. `db.json` will
  be used if not specified.

Options:
  --version        Show the version and exit.
  -b, --bind TEXT  Set address to bind, default as `:3000`
  --help           Show this message and exit.Note:Collections must be contained in your data file before starting the server, otherwise the server cannot decide the type of resources.Examples# Start with default config$json-server# Listen on port 3000$json-server-b:3000# Specify a json file$json-serverdb.json
Package: json-sett
json-settRead settings from and save them to a json file.Requirementsjson-convenienceInstallinstall using pip:python -m pip install json-settUsageimport the 'Settings' class:from json_sett import Settingsinitialize it:my_settings = Settings(file=<your_file_path>then access your settings as attributes of the 'my_settings' object:say your json file contains the key 'settingA' you can access its value like that:my_settings.settingAchange the value of a setting like that:my_settings.settingA = <your_new_value>this will NOT save that value to the fileto save all settings use:my_settings.save()File restrictionsThe settings must all be at the top level in the json file.This is a valid example:{"settingA":"valueA","settingB":14}This is an invalid example:{"settingA":"valueA","settingB":{"settingC":true}}Adding support for the invalid example e.g. being able to order settings in groups would be nice.
Might do that some time.
Package: jsonsh
jsonshDisclaimer : This is quite slow for bunch inserts,
Taking upto 0.0077 second for 1 file insert when 10000 files were inserted one by oneNote: I did the test on my laptop , which has i5-3337uInstallingpipinstall-Ujsonshif you are on Unix-like system, The performace can be increased by installing uvloop !pipinstall-UuvloopWhat is this !This is a silly package , that uses pydantic to store data in different json files.Data Fetched is in pydantic Model , which can be converted to dict using dict().All examples below have data returned as a Pydantic Model !UsageBase ExampleimportasynciofromjsonshimportTemplate,Instanceinstance=Instance("Data")#this is your data folder@instance.registerclassTest(Template):id:intage:intname:strasyncdefmain():idk=Test(id=10,age=13,name="hello")awaitidk.save()#this saves the file in your current working directoryasyncio.run(main())Finding and Updating DataThere are no advanced queries yet but you can find by id or particular valueimportasynciofromjsonshimportTemplate,Instanceinstance=Instance("Data")@instance.registerclassTest(Template):id:intage:intname:strasyncdefmain():data=awaitTest.find_one(id=10)print(data)#prints the data we founddata.name="Unknown"#changing nameawaitdata.save()#updating dataasyncio.run(main())Finding Multiple DataimportasynciofromjsonshimportTemplate,Instanceinstance=Instance("Data")@instance.registerclassTest(Template):id:intage:intname:strasyncdefmain():data=awaitTest.find_many(age=10)#finding all dict with age as 10print(data)#prints the lists of multiple dictsasyncio.run(main())Using IndexingimportasynciofromjsonshimportTemplate,Instanceinstance=Instance("Data")@instance.registerclassTest(Template):id:intage:intname:strclassMeta:indexes=["age","name"]"""this makes finding by age and name faster"""asyncdefmain():data=awaitTest.find_many(age=10)#finding all dict with age as 10print(data)#prints the lists of multiple dictsasyncio.run(main())Deleting files / entriesimportasynciofromjsonshimportTemplate,Instanceinstance=Instance("Data")@instance.registerclassTest(Template):id:intage:intname:strclassMeta:indexes=["age","name"]"""this makes finding by age and name faster"""asyncdefmain():data=awaitTest.delete_one(age=10)#deleting a file entry with age as 10data=awaitTest.delete_one(id=10)#deleting a file entry with id as 10print(data)#prints the lists of multiple dictsasyncio.run(main())Simple CachingfromjsonshimportTemplate,Instanceinstance=Instance("Data",cache_state=True,capacity=100)#this helps you to avoid reading files in finds
Package: jsonshell
jsonshellNavigating JSON documents just got a whole lot easier! Withjsonshell, you can navigate large and complex objects as if they were in a shell-like environment. Injsonshell, objects are treated as directories and can be navigated through with thecdcommand. You can also use thelscommand, which lists all the
keys/property names,getwhich retrives a value by key/property name, and more!Install it withpip install jsonshell, and then run eitherjsonshorjson.sh. Pass in the JSON object filename as the argument tojson.sh, and then use thehelpcommand to get started!
Package: json-simple-manager
JSON Simple ManagerPequena biblioteca para validação e manipulação de JSONs.InstalaçãoVocê pode baixar pelo pip:pip install json-simple-managerOu pelo próprio repositório:git clone git@github.com:Hoyasumii/JsonSimpleManager.gitou pelos submódulos do git:git submodule add git@github.com:Hoyasumii/JsonSimpleManager.gitCaso queira colocar o submódulo em uma pasta específica, basta adicionar o nome da pasta após o link do repositório.Métodos disponíveischecker->dictRetorna um dicionário com as chaves que estão:Faltando,Com valor erradoeChaves extras.Parâmetros:json: O JSON a ser validado.schema: O schema a ser usado na validação.dropKey->boolRetornaTruese a chave foi removida com sucesso,Falsecaso contrário.Parâmetros:json: O JSON a ser manipulado.key: A chave a ser removida.get->dictRetorna odicionáriodoJSON.Parâmetros:json: O JSON a ser manipulado.update->boolRetornaTruese oJSONfoi atualizado com sucesso,Falsecaso contrário.Parâmetros:json: O JSON a ser manipulado.key: A chave a ser atualizada.value: O valor a ser atualizado.Link do repositório
Package: json-simple-validator
JSON Simple ValidatorAboutThis is a simple JSON validator built for and tested using Flask applications.UsageTo install the validator:pip install json-simple-validatorSample usage of the validator:fromjson_simple_validatorimportfield_validation## Example Flask request@app.route("/post",methods=["POST"])defpost():validation_list=[{"field":"name"},{"field":"pass","alias":"Password"},{"field":"number","var_type":[int]}]# 	validation_list = [# 		# Each element is made up of the field that is being validated# 		# and the alias of the field that is to be displayed, should there be an error# 		# Sample dict:# 		# {"name": "", e.g "first_name"# 		# "alias[optional]": "", eg "First Name" If left out, title case of field name is used# 		# "var_type[optional]": "", eg [str, bool, int]# 		# "length[optional]": "[min, max(optional)]", eg [2, 10]# 		# "special_rules": ""} eg ["email"] Only email is supported for nowmessages=fieldValidation(request.json,validation_list)ifmessages:returnjsonify({"messages":messages}),422Post the following to the above endpoint:{"name":"","pass":"","number":"121231"}The following is returned:{"messages":["Name is empty.","Password is empty.","Number data type is not of the expected data type."]}
Package: json-sort
json-sortJust a tiny tool to sort keys in a json fileQuickstartFirst, install json-sort usingpip:sh-4.2$ pip install json-sortNext, usejson-sort-fromfileorjson-sort-fromremote:sh-4.2$ json-sort-fromremote http://headers.jsontest.com/
{
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Host": "headers.jsontest.com",
    "User-Agent": "python-requests/2.10.0",
    "X-Cloud-Trace-Context": "8de3c28b6c503d26d38c1c7d6111bfa6/11298559371430510765"
}ArgumentsTo see binaries usage, just set-h:usage: json-sort-fromfile [-h] [--output FILE] [--verbose] file

positional arguments:
  file                  input file

optional arguments:
  -h, --help            show this help message and exit
  --output FILE, -o FILE
                        output file (default: stdout)
  --verbose             increase output verbosityExample:sh-4.2$ json-sort-fromfile --verbose --output test2.json ../test.json
DEBUG   : Checking file: /tmp/test.json
DEBUG   : Saving to: /tmp/json-sort/test2.jsonLicenseApache License 2.0
Package: json-sorter
Simple python package to sort Json from files, strings, or dictionariesUsage:sorted_jsn = json_sort.sorter.sort_from_dict(jsn)sorted_jsn = json_sort.sorter.sort_from_file(jsn)sorted_jsn = json_sort.sorter.sort_from_string(jsn)One can use a custom sort method by providing a predicate to the methods as in…predicate={method_name_here}:
Package: json-source-map
JsonSourceMapCalculate JSON Pointers to each value within a JSON document along with the
line, column and character position for the start and end of that value. For
more information see:https://github.com/open-alchemy/json-source-map/wiki.For example:python-mpipinstalljson_source_mapfromjson_source_mapimportcalculateprint(calculate('{"foo": "bar"}'))The above prints:{'':Entry(value_start=Location(line=0,column=0,position=0),value_end=Location(line=0,column=14,position=14),key_start=None,key_end=None,),'/foo':Entry(value_start=Location(line=0,column=8,position=8),value_end=Location(line=0,column=13,position=13),key_start=Location(line=0,column=1,position=1),key_end=Location(line=0,column=6,position=6),),}Where:each key in the dictionary is a JSON path to an item,each value in the dictionarty contains the mapping of the item at the JSON
path which have the following properties:value_startis the start of the value,value_endis the end of the value,key_startis the start of the key (which isNoneat the root level and
for array items),key_endis the end of the key (which isNoneat the root level and for
array items) andeach of the above have the following properties:lineis the zero-indexed line position,columnis the zero-indexed column position andpositionis the zero-indexed character position in the string
(independent of the line and column).The following features have been implemented:support for primitive types (strings,numbers,booleansandnull),support for structural types (arrayandobject) andsupport for space, tab, carriage and return whitespace.
Package: jsonSpark
JsonSparkThis package is meant to give a python simplicity and feel to pyspark while handling json files.It is very simple to use and doesn't need extra information if you are using python.Installationpip install jsonSparkSample Usage:Import the packageimport jsonSparkPass the pyspark json file objectdf = sql.read.json("filename", multiLine=True) # or get from S3 bucketCreate a JsonSpark object.df = jsonSpark(df)See the schema if you wish.df.printSchema()Display the Datadf.show()Use it as python dictionarydf["key1"]["key2"]["key3"]["key4"].show()You can use the pyspark functions by converting the object back to pyspark object.pysparkObject = df._toDF()I will update the documentation and include a working example soon ....
Package: json-spec
This library implements several JSON specs, likeJSON Schema,JSON ReferenceandJSON Pointer:It works on python 3.6 and aboveIt is release under theBSD licenseInstallationThis library has only weak dependencies. You can simply use pip:$ pip install json-specRegading you needs, you can install more features. For example, this command
will enable colorated messages:$ pip install json-spec[cli]This one will enable ip format for json schema:$ pip install json-spec[ip]…CLI UsageThis module expose 2 cli commands.json-extractwill extract parts of your json document:$ json-extract '#/foo/1' --document-json='{"foo": ["bar", "baz"]}'
$ echo '{"foo": ["bar", "baz"]}' | json-extract '#/foo/1'
$ json-extract '#/foo/1' --document-file=doc.json
$ json-extract '#/foo/1' < doc.jsonjson-validatewill validate your document against a schema:$ json-validate --schema-file=schema.json --document-json='{"foo": ["bar", "baz"]}'
$ echo '{"foo": ["bar", "baz"]}' | json-validate --schema-file=schema.json
$ json-validate --schema-file=schema.json --document-file=doc.json
$ json-validate --schema-file=schema.json < doc.jsonLibrary usageLet say you want to fetch / validate JSON like objects in you python scripts.You can extract member of an object withJSON Pointer:from jsonspec.pointer import extract

obj = {
    'foo': ['bar', 'baz', 'quux']
}
assert 'baz' == extract(obj, '/foo/1')You can resolve member of any object withJSON Reference:from jsonspec.reference import resolve

obj = {
    'foo': ['bar', 'baz', {
        '$ref': '#/sub'
    }],
    'sub': 'quux'
}

assert 'quux' == resolve(obj, '#/foo/2')You can describe you data withJSON Schema:from jsonspec.validators import load

# data will validate against this schema
validator = load({
    'title': 'Example Schema',
    'type': 'object',
    'properties': {
        'age': {
            'description': 'Age in years',
            'minimum': 0,
            'type': 'integer'
        },
        'firstName': {
            'type': 'string'
        },
        'lastName': {
            'type': 'string'
        }
    },
    'required': [
        'firstName',
        'lastName'
    ]
})

# validate this data
validator.validate({
    'firstName': 'John',
    'lastName': 'Noone',
    'age': 33,
})Other examples can be found in thedocumentationor in thetests.
Package: jsonsqlquery
jsonsqlqueryQuery JSON using SQL.pip install jsonsqlqueryExamples# students.jsonl
{"name": "Alvin", "age": 25, "major": "Literature"}
{"name": "Kathy", "age": 31, "major": "Literature"}
{"name": "Pauline", "age": 11, "major": "Mathematics"}
{"name": "Nora", "age": 27, "major": "Mathematics"}
{"name": "Martin", "age": 54, "major": "Geology"}Inline SQL query:cat students.jsonl | jsonsqlquery --query 'select name, age from data where age > 30'SQL query from a file:cat students.jsonl | jsonsqlquery --query-file query.sqlCreate a SQLite database:cat students.jsonl | jsonsqlquery --create-db students.dbPython API:importjsonsqlquerystudents=[...]older_students=jsonsqlquery.query(students,"select name, age from data where age > 30")CaveatsBooleans are cast to integers.Data is assumed to fit in memory.
Package: jsonsteg
JSON steganographyWrite payload into JSON without modifying itInstallationInstall jsonsteg viaPyPI:pip install jsonstegCLI usageUse command line interface viajsonstegcommand.WritingWrite payloadmysecretto JSON found in filedata.json:jsonsteg write --input mysecret data.jsonWrite the contents of filemessage.txtas a payload to JSON of filedata.json:jsonsteg write --input-file message.txt data.jsonInstead of modifyingdata.jsonfile, you can output the altered JSON tooutput.jsonfile:jsonsteg write --input mysecret --output output.json data.jsonReadingWrite the payload of JSON in filedata.jsonand print it to console:jsonsteg read data.jsonInstead of printing, the output can also be saved to fileoutput.txt:jsonsteg read --output output.txt data.jsonHelpLearn more about possible options with these commands:jsonsteg --help
jsonsteg read --help
jsonsteg write --helpPython usageJsonsteg can also be used as a Python package:import jsonsteg

jsonsteg.DictionaryReader(json_dictionary)
jsonsteg.DictionaryWriter(json_dictionary, payload_bytes)
jsonsteg.ArrayReader(json_array)
jsonsteg.ArrayWriter(json_array, payload_bytes)Writer objects haveoutputproperty and reader objects havepayloadproperty.DevelopmentAfter cloning the git repository, install development dependencies
by running the following command in project root:poetry installRun unit tests withpoetry run invoke testRun coverage test withpoetry run invoke coverageand create HTML coverage report withpoetry run invoke coverage-reportPublish the package on pypi.org or test.pypi.org by one of the following commands:poetry run invoke publish
poetry run invoke publish-testWhen running either one of the commands above,
you must have PYPI token stored in an environment variable namedPOETRY_PYPI_TOKEN_PYPIorPOETRY_PYPI_TOKEN_TEST_PYPI, respectively.How is it done?Read more about the mechanismhere.
Package: json-storage-manager
json-storage-managerjson-storage-manageris a Python Package that simply manages the JSON files with the stored data of products and orders for a demo store API.Installationpipinstalljson-storage-manageratomicUsageatomicis basically used as a custom context manager for writing JSON files without downtime for the original file.
It simply loads the JSON file into memory and opens a temporary file using thetempfilePython Package, finally once the operation is finished it performs anos.replace()to replace the original file (which is an atomic operation on Linux systems).fromjson_storage_managerimportatomicwithatomic.atomic_write(str(json_file))astemp_file:withopen(str(json_file))asproducts_file:# get the JSON data into memoryproducts_data=json.load(products_file)# now process the JSON dataproducts_data.append({'uuid':"2299d69e-deba-11e8-bded-680715cce955",'special_price':111.0,'name':"Test Product"})json.dump(products_data,temp_file)
Package: jsonstore
A schema-free database for JSON documents, exposed through a REST API, with searching implemented using a flexible matching algorithm.A quick start:$pipinstalljsonstore$jsonstore*Runningonhttp://127.0.0.1:31415/Creating a document:$curl-vhttp://127.0.0.1:31415/-d'{"foo":"bar","baz":{"count":42}}'<HTTP/1.0201Created<Location:http://127.0.0.1:31415/72dcf1ee-8efd-4d7f-8ca1-2eda2bf85099<etag:"348f16ee0c0856d853117bde8413a4270d1d3487"{"foo":"bar","baz":{"count":42},"__id__":"72dcf1ee-8efd-4d7f-8ca1-2eda2bf85099","__updated__":"2012-05-09T20:33:36.928075+00:00"}Searching the store:$curl-g'http://127.0.0.1:31415/{"baz":{"count":"GreaterThan(40)"}}'[{"foo":"bar","baz":{"count":42},"__id__":"72dcf1ee-8efd-4d7f-8ca1-2eda2bf85099","__updated__":"2012-05-09T20:33:36.928075+00:00"}]It also has a Python API. The above code would be done like this:>>>fromjsonstore.clientimportEntryManager>>>fromjsonstore.operatorsimportGreaterThan>>>em=EntryManager('http://127.0.0.1:31415/')>>>em.create(foo="bar","baz"={"count":42})>>>results=em.search(baz={"count":GreaterThan(40)})Or like this, just for fun:>>>fromjsonstore.dslimportStore>>>store=Store('http://127.0.0.1:31415/')>>>{"foo":"bar","baz":{"count":42}}>>store>>>results=store|{"baz":{"count":GreaterThan(40)}}Please see the website formore examples.