Saravanan666/pypi-org huggingface dataset:
Package: jsonapi-orm
JSON:API ORMQuick and dirty ORM that maps JSON:API responses to object attributes.Free software: BSD licenseDocumentation:https://jsonapi-orm.readthedocs.io.How ToUseRequestsor (if you are a masochist) Python’s built-in urllib modules to make the request to your JSON:API service and from there pass the response to JSON:API ORM.So, first install requests and this lib:pipinstallrequestspipinstalljsonapi-ormSwitch to your Python code and use the magic!importrequestsfromjsonapi_ormimportresponse_to_obj# list of itemsr=requests.get('https://raw.githubusercontent.com/mislavcimpersak/jsonapi-orm/master/tests/responses/example_list.json')obj=response_to_obj(r.json())print('LIST OF ITEMS:')foriteminobj.data:print(item.title)# author is defined as a relationshipprint(item.author.twitter)# single itemr=requests.get('https://raw.githubusercontent.com/mislavcimpersak/jsonapi-orm/master/tests/responses/example_single.json')obj=response_to_obj(r.json())print('SINGLE ITEM')print(obj.data.title)# author is defined as a relationshipprint(obj.data.author.id)print(obj.data.author.twitter)CaveatsSince Python object attribute nameshave certain ruleslike not starting with a number or not containing “-” char, all such attributes can be accessed using.get()method. Ie.obj.data.author.get('first-name').If relationship is not described in more detail in theincludedpart of the response matching fails silently.For now, this lib does not lazily follow relationship links or anything like that. You can of course make a new request to the given link and pass that response to JSON:API ORM.For now, there is no check if response is a valid JSON:API response. But you’ll probably get that you are trying to parse an invalid response when things start to break.And last, this lib requires Python 3.5 or newer.History0.1.8 (2018-04-06)Added test config and basic tests.0.1.7 (2018-03-25)Using readme.rst for frontpage of the docs.0.1.7 (2018-03-25)Fixed pip install.0.1.6 (2018-03-25)Readme fix for pypi.0.1.5 (2018-03-25)Readme fix for pypi.0.1.4 (2018-03-25)Readme examples using slighty modified examples from jsonapi.org which are located in this repo.0.1.3 (2018-03-25)Fixed a bug when child data is non-existent.0.1.2 (2018-03-25)Fixed a bug when included is not present in response.0.1.0 (2018-03-24)First release on PyPI.
Package: jsonapi-pydantic
jsonapi-pydanticJSON:APIimplementation withPydantic.Descriptionjsonapi-pydanticprovides a suite of Pydantic models matching the JSON:API specification.Install$pipinstalljsonapi-pydanticOr use your python package manager.UsageObject with primary data:fromjsonapi_pydantic.v1_0importTopLevelexternal_data={"data":[{"type":"articles","id":"1","attributes":{"title":"JSON:API paints my bikeshed!","body":"The shortest article. Ever.","created":"2015-05-22T14:56:29.000Z","updated":"2015-05-22T14:56:28.000Z",},"relationships":{"author":{"data":{"id":"42","type":"people"}}},}],"included":[{"type":"people","id":"42","attributes":{"name":"John","age":80,"gender":"male"}}],}top_level=TopLevel(**external_data)print(top_level.dict(exclude_unset=True))"""{"data": [{"type": "articles","id": "1","attributes": {"title": "JSON:API paints my bikeshed!","body": "The shortest article. Ever.","created": "2015-05-22T14:56:29.000Z","updated": "2015-05-22T14:56:28.000Z",},"relationships": {"author": {"data": {"id": "42", "type": "people"}}},}],"included": [{"type": "people", "id": "42", "attributes": {"name": "John", "age": 80, "gender": "male"}}],}"""print(top_level.data)"""[Resource(type="articles",id="1",attributes={"title": "JSON:API paints my bikeshed!","body": "The shortest article. Ever.","created": "2015-05-22T14:56:29.000Z","updated": "2015-05-22T14:56:28.000Z",},relationships={"author": Relationship(links=None, data=ResourceIdentifier(id="42", type="people", meta=None), meta=None)},links=None,meta=None,)]"""LicenseSeelicense.md.
Package: jsonapi-requests
jsonapi-requestsPython client implementation for json api.http://jsonapi.org/Usage exampleimportjsonapi_requestsapi=jsonapi_requests.Api.config({'API_ROOT':'https://localhost/api/2.0','AUTH':('basic_auth_login','basic_auth_password'),'VALIDATE_SSL':False,'TIMEOUT':1,})endpoint=api.endpoint('networks/cd9c124a-acc3-4e20-8c02-3a37d460df22/available-profiles')response=endpoint.get()forprofileinresponse.data:print(profile.attributes['name'])# Example output: "162 Sushi"endpoint=api.endpoint('cookies')endpoint.post(object=jsonapi_requests.JsonApiObject(type='cookies',attributes={'uuid':'09d3a4fff8d64335a1ee9f1d9d054161','domain':'some.domain.pl'},))# Example output: <ApiResponse({'data': {'id': '81', 'attributes': {'uuid': '09d3a4fff8d64335a1ee9f1d9d054161', 'domain': 'some.domain.pl'}, 'type': 'cookies'}})>Orm exampleLets say we have api endpoint:https://localhost/api/2.0/car/2which returns{"data":{"id":"2","type":"car","attributes":{"color":"red"},"relationships":{"driver":{"data":{"id":"3","type":"person"}}}},"included":[{"id":"3","type":"person","attributes":{"name":"Kowalski"},"relationships":{"married-to":{"data":{"id":"4","type":"person"}}}},{"id":"4","type":"person","attributes":{"name":"Kowalska"},"relationships":{"married-to":{"data":{"id":"3","type":"person"}}}},]}Then we can run:importjsonapi_requestsapi=jsonapi_requests.orm.OrmApi.config({'API_ROOT':'https://localhost/api/2.0','AUTH':('basic_auth_login','basic_auth_password'),'VALIDATE_SSL':False,'TIMEOUT':1,})classPerson(jsonapi_requests.orm.ApiModel):classMeta:type='person'api=apiname=jsonapi_requests.orm.AttributeField('name')married_to=jsonapi_requests.orm.RelationField('married-to')classCar(jsonapi_requests.orm.ApiModel):classMeta:type='car'api=apicolor=jsonapi_requests.orm.AttributeField('color')driver=jsonapi_requests.orm.RelationField('driver')car=Car.from_id("2")car.color# request happens here# Example output: 'red'car.driver.name# Example output:  'Kowalski'car.driver.married_to.name# Example output: 'Kowalska'car.driver.married_to.married_to.name# Example output: 'Kowalski'Authorization HTTP header forwarding in Flask applicationWhen using jsonapi_requests with Flask, we can setjsonapi_requests.auth.FlaskForwardAuth()asAUTHconfiguration option to copy authorization header from current request context.
It can be useful when fetching resources from different microservices.Installation with flask support:pipinstalljsonapi-requests[flask]Example usage:importjsonapi_requestsapi=jsonapi_requests.Api.config({'API_ROOT':'https://localhost/api/2.0','AUTH':jsonapi_requests.auth.FlaskForwardAuth(),})DocumentationFor more documentation check ourwiki.
Package: json-api-smart
Json API SmartIs your client library which support ths JSON:API standard specified
onJSON:API.classBaseResource(JsonApiResource):@staticmethoddefbase_url(cls)->str:return"http://baseurl.com/"classPeople(BaseResource):id:str=resource_id()first_name:str=attribute()classArticle(BaseResource):id:str=resource_id()title:str=attribute()number:int=attribute()some_date:date=attribute(decoder=date.fromisoformat)some_optional:Optional[int]=attribute()author:People=relationship()Query it with:# http://baseurl.com/articles/101article=Article.find("101")article.id# 101article.title# JSON:API paints my bikeshed!article.number# 1article.some_optional# Nonearticle.author.id# "9"article.author.first_name# "Dan"Query resourcesCall your resources by building chains:# http://baseurl.com/articlesarticles=Article.all()# http://baseurl.com/articles?price=5articles=Article.with_params(price=5).all()# http://baseurl.com/articles?filter[author]=101articles=Article.where(author=101).all()# http://baseurl.com/articles/101articles=Article.find("101")
Package: jsonapp-package
jsonappA command line utility that helps dealing with JSON data.FeaturesFormat JSON stringsDocumentationhttps://jsonapp.readthedocs.ioCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.2 (2017-05-25)Fix setup.py packages parameter.0.1.1 (2017-05-25)Fix import bug.0.1.0 (2017-05-17)Initial commit.
Package: jsonapy
JSON:APy - Loading and Dumping JSON:API in PythonWIP:this library is still in early development phase.jsonapyis a Python library for dumping models intoJSON:API-compliantJSON.InstallationWithpip:pip install jsonapyBasic usage overviewThis package lets you define models and dump them into dict with the JSON:API
structure. First, define a resource:importjsonapyclassPersonResource(jsonapy.BaseResource):id:intfirst_name:strlast_name:strclassMeta:resource_name="person"You can now dump an instance of this resource into JSON:API-structured dictionary:guido=PersonResource(id=1,first_name="Guido",last_name="Van Rossum")data=guido.jsonapi_dict(required_attributes="__all__")The resultingdatadictionary can be represented by:{'type':'person','id':1,'attributes':{'firstName':'Guido','lastName':'Van Rossum'}}DocumentationThe complete documentation can be foundhere.
It is built withpdoc.RoadmapRefer tothe projectto view the roadmap-related issues.
Package: json-as-db
JSON-as-DBUsing JSON as very lightweight database>>>db=Database()>>>db.load('output.json')# Load database from file>>>db.add([{# Add items what you want to add..."id":"1002",..."type":"Chocolate"...})['FqkmbYFSCRCAHQWydhM69v','RUJGcVBFANvNRReXa8U3En']>>>db.save('output.json',json_kwds={'indent':4})# Just save it into file.// output.json{"created_at":"2022-12-25T16:50:02.459068","creator":"json_as_db","data":{"FqkmbYFSCRCAHQWydhM69v":{"id":"1001","type":"Regular"},"RUJGcVBFANvNRReXa8U3En":{"id":"1002","type":"Chocolate"}},"updated_at":"2022-12-28T16:51:36.276790","version":"1.0.0"}DocumentationRead the Docs -https://json-as-db.readthedocs.io/InstallationInstalling via pip:pipinstalljson-as-dbInstalling via GitHub repository,gitclonehttps://github.com/joonas-yoon/json-as-db.git
pipinstall-ejson-as-dbContributingContributing guidelines can be foundCONTRIBUTING.md.Welcome all contributions to the community and feel free to contribute.LicenseUnder the MIT license. See theLICENSEfile for more info.
Package: jsonast
json astRequirementPython 3.8+FeatureSpecializing in dealing with tree structuresFully compatible with jsonCan be output as xmlCan be output as jsonmlMotivationWhere are the standard structures for annotated tree structures?xmlis the most common, but it would be nice to have ajsoncompatible and highly readable structure.jsonmlis hard to see.jsonlogicis good for operations, but not good for grammar.Contributepoetry install
pre-commit install
source .venv/bin/activate
make
Package: jsonatago
jsonatago: JSONata for Pythonjsonatago is a Python library that enables you to evaluate JSONata expressions. This project aims to bring the power and flexibility of JSONata to Python developers.CreditsThis project uses the Go implementation of JSONata from jsonata-go. All credit for the Go implementation goes to the authors and contributors of jsonata-go.InstallationTo install jsonatago, you can use pip:pipinstalljsonatagoUsageHere's a simple example that demonstrates how to evaluate a JSONata expression:pythonfromjsonatagoimportJsonataJSONATA_TEST_DATA={"Account":{"Order":[{"Product":[{"Price":10,"Quantity":2},{"Price":5,"Quantity":5}]},{"Product":[{"Price":20,"Quantity":1},{"Price":15,"Quantity":3}]}]}}expr=Jsonata("$sum(Account.Order.Product.(Price * Quantity))")print(expr.evaluate(JSONATA_TEST_DATA))This will output the sum of all Price * Quantity for each product in each order.You can use as well direct method for compilation and evaluation in one step.
pythonfromjsonatagoimportjevalJSONATA_TEST_DATA={"Account":{"Order":[{"Product":[{"Price":10,"Quantity":2},{"Price":5,"Quantity":5}]},{"Product":[{"Price":20,"Quantity":1},{"Price":15,"Quantity":3}]}]}}print(jeval(JSONATA_TEST_DATA,"$sum(Account.Order.Product.(Price * Quantity))"))ContributingIf you'd like to contribute to this project, please feel free to open an issue or submit a pull request.LicenseThis project is licensed under the MIT License. See the LICENSE file for details.
Package: jsonator
JSONatorDescriptionThis module provides a command-line interface for formatting JSON files.
It takes a path to either a JSON file or a directory containing JSON files
as input and can recursively scan subdirectories for JSON files. The module
returns an exit code indicating whether any files were reformatted or if there
were any errors.UsageThe main() function is the entry point for the module and returns an exit code
indicating the result of the JSON formatting operation. The following arguments
can be passed to the main() function:path: A required argument that specifies the path to the JSON file or directory containing JSON files to be formatted.--recursive or -r: An optional flag that specifies whether to scan subdirectories for JSON files.--check: An optional flag that indicates whether to perform a dry run and return the status without actually reformatting the files. The exit code will indicate whether any files would be reformatted or if there were any errors.--diff: Don't write the files back, just output a diff for each file on stdout.--color: Show colored diff. Only applies when--diffis given.--sort-keys: Sort the output of dictionaries alphabetically by key.Available on Python 3.5+.--no-ensure-ascii: Disable escaping of non-ASCII characters.Available on Python 3.9+.--indent: Separate items with newlines and use this number of spaces for indentation.--tab: Separate items with newlines and use tabs for indentation.--no-indent: Separate items with spaces rather than newlines.--compact: Suppress all whitespace separation (most compact).--indent, --tab, --no-indent, --compact — mutually exclusive options for whitespace control. Available on Python 3.9+.The module uses the ReturnCode enum to indicate the exit code of the formatting operation. The possible exit codes are:0: Indicates that no files would be reformatted.1: Indicates that some files would be reformatted.122: Indicates that the specified file or directory was not found.123: Indicates that there was an internal error.Example usage:$ jsonator /path/to/json/file.json --checkDev:Build package$ python -m buildCheck package$ twine check dist/*Publish package$ twine upload dist/*
Package: json-autocomplete
JSON AutocompleteThis library offers a simple function to complete any prefix of a valid JSON string, in a way that makes it a valid JSON again (e.g. by closing all open brackets and quotes), in a minimal way.There is only one function,json_autocomplete(json_prefix: str) -> str, which takes a prefix of a valid JSON string and returns a valid JSON string that is the shortest possible completion of the prefix.The heck did I develop this for? When streaming a response from a LLM like ChatGPT, where the model generates a JSON string, you can render it before the model is done generating the response.Another use case could be when you want to allow the user to enter a JSON string, but you want to offer autocomplete suggestions. You can use this function to get the shortest possible completion of the prefix the user has entered, and then offer that as a suggestion.Examples>>>json_autocomplete('')'null'>>>json_autocomplete('n')'null'>>>json_autocomplete('tr')'true'>>>json_autocomplete('-')'-0'>>>json_autocomplete('2.')'2.0'>>>json_autocomplete('[')'[]'>>>json_autocomplete('{')'{}'>>>json_autocomplete('{"')'{"": null}'>>>json_autocomplete('{"a": 1, "b": 2')'{"a": 1, "b": 2}'Installationpipinstalljson-autocompleteThen, simply import the function:fromjson_autocompleteimportjson_autocompletejson_autocomplete('{"a": 1, "b": 2')
Package: jsonbase
JSONBASEDescription:jsonbase is a simple database moduleyou can use it to store a small amount of databut that doesn't mean that you can store a big amount of dataWhy use jsonbase?jsonbase is simple and easy to useWill my data safe?We have used json for over 1 monthand yes, your data will safeUsageimportjsonbasedatabase=jsonbase.database('my_database')database.create()data=database.get()data['Variable']='value'data['List']=['element','item']data['Dict']={'key':'value'}database.save(data)Quick LinkDocs
Package: jsonbox
jsonbox-pythonPython wrapper forhttps://jsonbox.io(with support for V2 features)Installationpip install jsonboxUsagefromjsonboximportJsonBox# generate unique box idMY_BOX_ID=JsonBox.get_new_box_id()# create instancejb=JsonBox()data=[{"name":"first","age":25},{"name":"second","age":19}]# write dataresult=jb.write(data,MY_BOX_ID)# get record id of written datarecord_ids=jb.get_record_id(result)# read recordprint(jb.read(MY_BOX_ID,record_ids[0]))# read all records in boxprint(jb.read(MY_BOX_ID))# get metadata for boxprint(jb.get_meta(MY_BOX_ID))# read all records in box with sortprint(jb.read(MY_BOX_ID,sort_by="age"))# read records in box with sort matching query (see documentation for syntax)print(jb.read(MY_BOX_ID,query="name:firs*"))print(jb.read(MY_BOX_ID,query="age:=19"))# read records with limitprint(jb.read(MY_BOX_ID,limit=1))# read records with skipprint(jb.read(MY_BOX_ID,skip=1))# update datadata={"name":"Bob","age":23}jb.update(data,MY_BOX_ID,record_ids[0])# read updated dataprint(jb.read(MY_BOX_ID))print(jb.read(MY_BOX_ID,record_ids[0]))# delete records matching to queryprint(jb.delete(MY_BOX_ID,query="age:=23"))# delete recordsjb.delete(MY_BOX_ID,record_ids[1])# write to a private boxMY_PRIVATE_BOX_ID=JsonBox.get_new_box_id()api_key=jb.get_new_api_key()result=jb.write(data,MY_PRIVATE_BOX_ID,api_key=api_key)record_id=jb.get_record_id(result)# update a private boxdata={"name":"David","age":35}jb.update(data,MY_PRIVATE_BOX_ID,record_id,api_key=api_key)# delete a private boxjb.delete(MY_PRIVATE_BOX_ID,record_id,api_key=api_key)Private BoxAddapi_keyto write/update/delete as shown above.read is always accessible, even with out anapi_key.A valid and uniqueapi_keycan be generated usingget_new_api_key()Query ParamsAs supported (and documented) byhttps://github.com/vasanthv/jsonboxYou can query by constructing a query string and passing it to thequeryparameter:name:arya%20stark,age:>13The above sample will look for the namearya starkand age greater than 13.You can filter onNumber,String&Booleanvalues only.Filters for Numeric values.SampleTo filter values greater than or less than a specific valueage:>10orage:<10To filter values greater (or less) than or equal to a specific valueage:>=10orage:<=10To filter values that match a specific value.age:=10Filters for String values.SampleFilter values that start with a specific stringname:arya*Filter values that end with a specific stringname:*starkFilter values where a specific string appears anywhere in a stringname:*ya*Filter values that match a specific stringname:arya%20starkYou can combine multiple fields by separating them with commas as shown below:name:arya%20stark,age:>13,isalive:trueDeleting recordsThere are two ways to delete records (see examples above for both)Provide therecord_idProvide aqueryparameter, with the same syntax used for filtering on readUse your own instance of jsonboxjb = JsonBox(service_host="https://my-jsonbox-server.com")LicenseMIT
Package: json-build
json-buildjson-build is a package that allows developers to build and save JSON files quickly.Installationpipinstalljson-buildCreate a new JSON object to build uponfromjson_buildimportJSON_Objectnew_json=JSON_Object(outer=[])# 'outer' argument is optional# if 'outer=[]' is passed it will wrap the JSON object in an array (Python list)# otherwise, it will be a JSON object (Python dictionary)Nest objects inside the JSON objectnew_json.add_object(unique_name="people",keyword="people",data={},)new_json.add_object(unique_name='person_1',keyword='person1',data={"first_name":"Michael","last_name":"Myers"},parent='people',)new_json.add_object(unique_name='relative_1',keyword='relative',data={"first_name":"Laurie","last_name":"Strode","relation":"Sister"},parent='person_1')new_json.add_object(unique_name='person_2',keyword='person2',data={"first_name":"Jason","last_name":"Voorhees"},parent='people',)new_json.add_object(unique_name='relative_2',keyword='relative',data={"first_name":"Pamela","last_name":"Voorhees","relation":"Mother"},parent='person_2')new_json.add_object(unique_name='movies',keyword='movies',data=['Halloween','Friday the 13th','Nightmare on Elm Street',],)# 'parent' argument is optional; if unpassed, the object will be added to the JSON object's first level# Note that 'parent' uses the unique_name of the parent object, and not the keywordCreate the JSON objectnew_json.create()Save the JSON object to a filenew_json.save(file_name="killer_names",location_path="C:/Users/fkrueger/Desktop/")# 'location_path' argument is optional; if unpassed it will save the file to the root of your local projectResultant JSON object[{"people":{"person1":{"first_name":"Michael","last_name":"Myers","relative":{"first_name":"Laurie","last_name":"Strode","relation":"Sister"}},"person2":{"first_name":"Jason","last_name":"Voorhees","relative":{"first_name":"Pamela","last_name":"Voorhees","relation":"Mother"}}},"movies":["Halloween","Friday the 13th","Nightmare on Elm Street"]}]
Package: json-builder
json_builderBuild or modify json objects incrementally using json pathsInstallationThe quick way:pipinstalljson_builderUsageBefore start, check the json path syntax:https://goessner.net/articles/JsonPath/Add new keyroot_object = {"a": 10}
JsonBuilder.add(root_object, "$.b", 20)
JsonBuilder.add(root_object, "$.c.d.e", 30)
print(root_object)

Output:
{
  'a': 10,
  'b': 20,
  'c': {
    'd': {
      'e': 30
    }
  }
}Modify existing key valueroot_object = {
        'a': 10,
        'b': 20,
        'c': {
            'd': {
                'e': 30
            }
        }
    }
JsonBuilder.add(root_object, "$.c.d.e", "test")
print(root_object)

Output:
{
  'a': 10,
  'b': 20,
  'c': {
    'd': {
      'e': 'test'
    }
  }
}Create a listroot_object = {
        'a': 10,
    }
JsonBuilder.add(root_object, "$.b[0]", "1")
JsonBuilder.add(root_object, "$.b[1]", "2")
JsonBuilder.add(root_object, "$.b[2]", {"c": 20})
print(root_object)

Output:
{
  'a': 10,
  'b': [
    '1',
    '2',
    {
      'c': 20
    }
  ]
}Modify existing list indexroot_object = {
        'a': 10,
        'b': [
            '1',
            '2',
            {
                'c': 20
            }
        ]
    }
JsonBuilder.add(root_object, "$.b[2]", '3')
print(root_object)

Output:
{
  'a': 10,
  'b': [
    '1',
    '2',
    '3'
  ]
}ExceptionsObject is not json serializableValues that are not json serializable are not allowedroot_object = object()
JsonBuilder.add(root_object, "$.b[4]", '3')
print(root_object)

root_object = {}
JsonBuilder.add(root_object, "$.b[4]", object())
print(root_object)

Output:
TypeError: Object <object object at 0x00000295240A4D20> is not JSON serializable.Invalid json pathCheck the json path syntax:https://goessner.net/articles/JsonPath/root_object = {}
JsonBuilder.add(root_object, ".b[4]", 3)
print(root_object)

Output:
ValueError: Invalid json path ".b[4]". Check https://goessner.net/articles/JsonPath/ for more details.Object is not a dictionaryroot_object = {
  'a': []
}
JsonBuilder.add(root_object, "$.a.b", 1)
print(root_object)

Output:
Exception: Can't insert key "b", object is not a dictionary. Root: {'a': []}. Json path: $.a.bObject is not a listroot_object = {
  'a': {}
}
JsonBuilder.add(root_object, "$.a[0]", 1)
print(root_object)

Output:
Exception: Can't insert on position "0", object is not a list. Root: {'a': {}}. Json path: $.a[0]Previous list index not definedList items must be added consecutivelyroot_object = {
  'a': []
}
JsonBuilder.add(root_object, "$.a[0]", 1)
JsonBuilder.add(root_object, "$.a[2]", 2)
print(root_object)

Output:
Exception: Index to big "2", previous list indexes not defined. Root: {'a': [1]}. Json path: $.a[2]LicenseMIT