Saravanan666/pypi-org huggingface dataset:
Package: json-pattern-validator
Validation schema based of a json string or a dictSchema:You must define a dict which will match with a json/dict under testadd!at begin fo key for to indicate a required fieldIn value of that key you will need specify a validator for such fieldThat validator have to be a valid default validator or you can add your ownEXAMPLE_SCHEMA = {
        "!version": "string",
        "!email": "email",
        "!data": {
            "!Id": "number",
            "title": "string"  # optional
            },
        }Usage:Example:ok_json = {
        "version": "1.0.1a",
        "email": "test@test.com",
        "data": {
            "Id": 231,
            "title": "description"
        }
    }
    e = JSONEvaluator()
    e.set_schema(EXAMPLE_SCHEMA)
    e.evaluate(ok_json)
    if e.ok:
       print("Dict validate")
    else:
       print("errors found:")
       print(e.errors)
Package: json_payload_validator
Little Python package that formats validation error messages fromjsonschema.
You should use this package if you want a stand alone json validator decoupled from any framework.Reason of beingjsonschema is really cool but its validation error messages suck as they’re meant for developers, not end users.
So if you have an API that uses jsonschema to validate json payloads and want to return nicer error messages to your
end users you can use this package :)How it works3 simple rules:If you don’t send a required property in the payload you’ll get the message'foo' is a required property.If validation fails the validation rule will be returnedValidation of property 'foo' failed: {'minLength': 2, 'type': 'string', 'maxLength': 50}.If you addmessageproperty in a validation rule its value will be returned instead of the ruleValidation of property 'foo' failed: Custom error message.Usagepip install json_payload_validatorSuccessful validation examplefromjson_payload_validatorimportvalidateschema={'type':'object','properties':{'name':{'type':'string','minLength':2,'maxLength':50},},'required':['name']}payload={'name':'John Maus'}error=validate(payload,schema)print(error)# NoneRequired property examplefromjson_payload_validatorimportvalidateschema={'type':'object','properties':{'name':{'type':'string'},},'required':['name']}payload={}error=validate(payload,schema)print(error)# 'name' is a required propertyValidation rule failure examplefromjson_payload_validatorimportvalidateschema={'type':'object','properties':{'name':{'type':'string',{'minLength':2,'type':'string','maxLength':50}},},'required':['name']}payload={'name':555}error=validate(payload,schema)print(error)# Validation of property 'name' failed: {'minLength': 2, 'type': 'string', 'maxLength': 50}Custom error message examplefromjson_payload_validatorimportvalidateschema={'type':'object','properties':{'name':{'type':'string','message':'Name must be a string'},},'required':['name']}payload={'name':555}error=validate(payload,schema)print(error)# Validation of property 'name' failed: Name must be a string
Package: jsonpickler
JSONpickler===========Version 0.1Python JSON encoder and decoder supporting objects, tuples and complex keys.from jsonpickler import dumps, loadss={'a':'demo',(1,2):{3:4},'obj':Test()}jsonstr=dumps(s)decodeddata=loads(jsonstr)HISTORY=======0.1 (2013-05-10)----------------* Initial version. Seems to work OK, but i have to make sometests.
Package: json-plist-mobileconfig
JSON-Plist-Mobileconfig ConverterJSON-Plist-Mobileconfig Converter is a Python package that facilitates the conversion between JSON, plist, and mobileconfig ("Custom Settings") formats.FeaturesJSON to Plist: Convert JSON files to plist format.Plist to JSON: Convert plist files to JSON format.Plist to Mobileconfig: Embed plist files into a mobileconfig file for distributing, or forcing, custom settings on Apple devices.JSON to Mobileconfig: Directly convert JSON files to mobileconfig format for distributing, or forcing, custom settings on Apple devices.InstallationYou can install the package from PyPI using the following command:pipinstalljson-plist-mobileconfigAlternatively, you can clone the repository to your local machine:gitclonehttps://github.com/rjocoleman/json-plist-mobileconfig.gitNavigate to the project directory:cdjson-plist-mobileconfigAlthough the script uses only the Python standard library, if you add any external dependencies in the future, you can install them using:pipinstall-rrequirements.txtUsageAs a Command-Line ToolYou can use the script as a command-line tool with the following syntax:json-plist-mobileconfiginput_file[--plist][--json][--mobileconfig][options](Or not installed via the PyPI packagepython ./json-plist-mobileconfig.py)Argumentsinput_file: The path to the input JSON or plist file. (Required)--plist: If specified, outputs a plist file.--json: If specified, outputs a JSON file.--mobileconfig: If specified, outputs a mobileconfig file with embedded plist data.Options--uuid UUID: Specifies the UUID for the mobileconfig file. A new UUID is generated if not specified.--removal_disallowed: Disallows removal of the mobileconfig file. Default is false.--identifier IDENTIFIER: Specifies the identifier for the mobileconfig file. Default is 'com.example.customsettings'.--payload_version PAYLOAD_VERSION: Specifies the payload version for the mobileconfig file. Default is 1.--payload_display_name PAYLOAD_DISPLAY_NAME: Specifies the payload display name for the mobileconfig file. Default is 'Custom Settings'.--version: Displays the version of the script.As a LibraryYou can also use the script as a library in other Python scripts. Here's an example of how to use the functions in the script:importscript_name# Read data from a JSON or plist filedata=script_name.read_input_file('input_file.json')# Convert data to plist formatplist_data=script_name.convert_to_plist(data)# Convert data to JSON formatjson_data=script_name.convert_to_json(data)# Create a mobileconfig file with embedded plist datamobileconfig_data=script_name.create_mobileconfig(plist_data,uuid,removal_disallowed,identifier,payload_version,payload_display_name)CreditsmcxToProfile- does something similar, and has a different feature set but relies on external libraries and was harder for me to runLicenseMIT
Package: jsonplustypes
Uses builtin json. but adds a lookup dictionary with functions that encode/decode specific types.TO INSTALL$ pip install jsonplustypesby default it is able to:encode datby default it is able to:* encode datetime,date and bson ObjectId's to and fromcustom TYPE/VALUE dict* dump with float precision if you want to cut off digitsCustom objects are encoded in the following verbose dict format (with datetime as example):{_TYPE_TAG:"DATETIME",_VALUE_TAG:date_string}the github repo holds a reference javascript implementation of the same json serialization/deserializationCHANGELOG:==========0.7.9:added try, except for attr err in iteritems0.7.8:removed bad print statement0.7.7fixed so now uses str(type(obj).__name__)0.7.6:now loads and dumps iso datetime strings with the format:"%Y-%m-%dT%H:%M:%S.%fZ"0.7.5:fixed the strange float precision limiternot based on monkeypatching the json.encoder.FLOAT_REPR and json.encoder.c_make_encoder, which means it now runs without the C speedups0.7:added encoder for datetime.date and bson ObjectId0.6:fixed bug - JSONEncoder -> json.JSONEncoder
Package: jsonpointer
python-json-pointerResolve JSON Pointers in PythonLibrary to resolve JSON Pointers according toRFC 6901See source code for examplesWebsite:https://github.com/stefankoegl/python-json-pointerRepository:https://github.com/stefankoegl/python-json-pointer.gitDocumentation:https://python-json-pointer.readthedocs.org/PyPI:https://pypi.python.org/pypi/jsonpointerTravis CI:https://travis-ci.org/stefankoegl/python-json-pointerCoveralls:https://coveralls.io/r/stefankoegl/python-json-pointer
Package: json_pointer
JSON PointerSimple implementation of the json-pointer spec:http://tools.ietf.org/html/rfc6901UsageJSON pointer make it possible to retrieve arbitrary sub-objects from json objects.>>> import json_pointer
>>> data = {'a': {'b': 'c'}, 'd': ['e', 'f', 'g']}>>> json_pointer.Pointer('/a/b').get(data)
 'c'
>>> json_pointer.Pointer('/d/1').get(data)
'f'It is also possible to set and unset data using pointers.>>> data = {'a': {'b': 'c'}, 'd': ['e', 'f', 'g']}>>> json_pointer.Pointer('/a/b').set('d')
>>> json_pointer.Pointer('/a/c').set('h')
>>> data
 {'a': {'d': 'c', 'c': 'h'}, 'd': ['e', 'f', 'g']}>>> json_pointer.Pointer('/d/1').unset(data)
 {'a': {'d': 'c', 'c': 'h'}, 'd': ['f', 'g']}
Package: jsonpointer-helpers
jsonpointer-helpersHelpers for JSON pointers described byRFC 6901.Installation$ pip install jsonpointer-helpersUsage>>> import jsonpointer_helpers as jp
>>>
>>> jp.build({'foo': {'bar': 42}})
{'/foo/bar': 42}
>>>
>>> jp.build_pointer(['foo', 'bar'])
'/foo/bar'
>>>
>>> jp.parse_pointer('/foo/bar')
['foo', 'bar']
>>>
>>> jp.escape_token('foo~bar')
'foo~0bar'
>>>
>>> jp.unescape_token('foo~0bar')
'foo~bar'
>>>Testing and lintingContributingTo work on thejsonpointer-helperscodebase, you'll want to clone the project locally and install the required dependencies viapoetry:$ git clone git@github.com:Gr1N/jsonpointer-helpers.git
$ poetry installTo run tests and linters use command below:$ poetry run toxIf you want to run only tests or linters you can explicitly specify which test environment you want to run, e.g.:$ poetry run tox -e py37-testsLicensejsonpointer-helpersis licensed under the MIT license. See the license file for details.
Package: json-position-mapper
JSON MapperTooling that can map a given JSON key to either a file offset or a line/column pairThis tooling is still in beta and the API is subject to change.PurposeThis was designed to support a custom VS code JSON validator in an unrelated product. We needed to be able to know information such aspeople.0.namestarted at line 8 column 2 and ended at line 8 column 12, or thatpeople.0(the entire sub-object) spanned from line 6 column 1 through line 18 column 1.InterfaceThe primary interface to the JSON mapper isjson_mapper.mapper.JSONMapper. This is initialized with a seekable IO object (such as a file or StringIO) and has the following public properties and methods:JSONMapper.offsets: A cached property that contains a mapping of all the keys in the object to their relative file positions. The keys are tuples representing the path to get to a given JSON object(('people', 0, 'name')) in my example above and the offsets are named tuples withstartandendparameters. The offsets are inclusive at the start and non-inclusive at the end - the same as Python slice mechanics.JSONMapper.get_position(key: Tuple): Get the start and end line/column offsets for a given JSON key. Ajson_mapper.mapper.Positionobject is returned which hasstart_line,start_col,end_line, andend_colstored values, and aneditorcalculated property, which returns ajson_mapper.mapper.EditorPositionJSONMapper.get_position(key: Tuple).editor: Get thejson_mapper.mapper.EditorPositionobject for a given JSON key. This is very similar to the non-editor based object, except that it uses inclusive starts and ends and all values are one based. This is what you will want to use if you are trying to use this library to write a VS Code task that highlights JSON files for problems.ExampleInstallation:pip install json-position-mapperSample JSON file:example.json{"people":[{"name":"Adam","favoriteFood":"pie","attributes":{"eyeColor":"orange","height":"12 foot","happy":true}},{"name":"David","favoriteFood":"sushi","attributes":{"eyeColor":"fuschia","height":"4 inches","happy":null}}]}Example Python file:example.pyfromioimportStringIOfromjson_mapper.mapperimportJSONMapper,Position,Offsetwithopen("example.json")asf_in:in_memory=StringIO(f_in.read())mapper=JSONMapper(in_memory)# Get the entire slice offset of the 'people' keyprint(mapper.offsets[("people",)])# Output: Offset(start=16, end=488)# Get the slice offset for people.0.nameprint(mapper.offsets[("people",0,"name")])# Output: Offset(start=48, end=54)# Get the line/column start and end for people.0# This is what we would use if we were to use Python to split the file on line and then use slice mechanicsprint(mapper.get_position(("people",0)))# Output: Position(start_line=2, start_col=8, end_line=10, end_col=9)# This is what we would use to highlight in something like VS Codeprint(mapper.get_position(("people",0)).editor)# Output: EditorPosition(start_line=3, start_col=9, end_line=11, end_col=9)
Package: json-post
json-postTool for posting JSON to an API, broken into pagesWhy would you need this?This tool is for a very specific use-case. Let's say you have 80MB of data that you want to send to an API. The data is a big JSON file with thousands of items in it - but the API you are using can only accept 50 items at a time.json-postcan take that big JSON file and break it up into batches, then send each batch to the API in turn.json-post my-big-json-file.json https://example.com/my-api --batch-size 50InstallationInstall this tool usingpip:$ pip install json-postOptions-hor--header KEY VALUETakes two arguments to specify an HTTP header, for example to send an authorization token you might use:json-post d.json https://example.com/api --header Authorization "Bearer x...."--log FILENAMEA filename to log the JSON responses from the API to, as newline-delimited JSON.--batch-size NThe batch size to use. Omit this and the data will be sent in a single request.--stop-after NSend this many items and then stop. Useful for debugging.--reverseSend the items from the file in reverse order.--shuffleSend the items from the file in random order.--http-read-timeout NTimeout (in seconds) for network read operations.--filter 'item.get("field")'Filter the items in the array using this Python expression before sending them. The variableitemwill refer to each item in the list.--countOutput the number of items that would be sent and then exit. Useful for testing that your--filteroperation works as expected.DevelopmentTo contribute to this tool, first checkout the code. Then create a new virtual environment:cd json-post
python -mvenv venv
source venv/bin/activateOr if you are usingpipenv:pipenv shellNow install the dependencies and tests:pip install -e '.[test]'To run the tests:pytest
Package: json-processor
Simply convert one JSON to another.Easy to use.Create a simple JSON conversion schema and pass it to processorRich.It usesjsonpointerso you can create complex processorsExamplefromjson_processorimportjson_processschema={"type":"object","value":{"simple_key":"Just a string","values":{"type":"array","from":{"type":"jsonpointer","value":"/data/items"},"value":{"type":"object","value":{"id":{"type":"jsonpointer","value":"/$value/foreign","cast":"integer"},"name":{"type":"jsonpointer","value":"/$value/name"}}}}}}data={"data":{"items":[{"foreign":"100","name":"Item 1"},{"foreign":"150","name":"Item 2"}]}}print(json_process(schema,data))# Outputs:# {'simple_key': 'Just a string', 'values': [{'id': 100, 'name': 'Item 1'}, {'id': 150, 'name': 'Item 2'}]}InstallationFrom PyPipipinstalljson_processorCommand line toolAfter installation you can usejson_processutility:json_process<schema_file><json_file>
Package: jsonproject
JsonprojectEasily manage your projectsWhat is jsonproject?jsonproject is a simple, easy to use, and powerful project configuration manager. It is a JSON based configuration project manager that allows you to manage your projects in a simple and easy way. Its just like npm'spackage.jsonfile.InstallationTo install jsonproject, just run the following command:pip install jsonprojectUsageInitializeTo initialize a new project, runjsonproject init. This will walk you through the process of creating a new project.jsonproject will ask you for the following information:Project nameProject descriptionProject authorProject licenseProject versionProject homepageProject emailProject actionsIt will then create a new project directory and a newproject.jsonfile.{"name":"Example","description":"This is an example project","version":"0.1","author":"John Doe","license":"GNU-3","url":"www.example.com","email":"example@example.com","languages":["python","javascript","c++"],"actions":{"build":"example build","test":"example test","install":"example install","uninstall":"example uninstall"}}SearchTo search for a project, runjsonproject search. This will search for a project in the current directory and all subdirectories.projects in C:\Projects\
name:Example version:0.1 location:.\exampleInfoTo get information about a project, runjsonproject info. This will print out the information about the project.name:Example
version:0.1
description:This is an example project
author:John Doe
license:GNU-3
url:www.example.com
email:example@example.com
languages:
        python
        javascript
        c++
actions:
        build:example build
        test:example test
        install:example install
        uninstall:example uninstall
Package: jsonprop
# AboutFine-grained control of JSON serialization using decorators.# WhyBecause sometimes you just need to serialize a few properties/excludenull values/rename fields and want to do it declaratively.# UsageImportsfrom jsonprop import JsonObject, json_propertyInherit from JsonObjectclass MyJsonObjectClass(JsonObject):def __init__(self):self._test_prop = NoneDecorate getter method with @json_property...@json_property('json_test_prop', False)def get_test_prop(self):return self._test_propuse json() method inherited from JsonObject to serializejson = myclass.json()Alternatively, use the json_field to concisely specify a set of serializable fieldson an object that may be assigned to as descriptors.class MyObj(JsonObject):field_one = json_field('fieldOne')field_two = json_field('fieldTwo')Which may be serialized in the same manner as above.JsonObject supports the use of keyword arguments at object initialization time. Theexample class above may be conveniently instantiated as follows:myobj = MyObj(field_one = 'one', field_two = 'two')# APIThe general form of the decorator is:@json_property(name, include_null)where name is the desired JSON field name for the python property andinclude_null is a boolean that indicates whether or not null values willbe included in the serialization. By default this value is True and null valueswill be serialized. If this is set to False, the field will be omitted entirelyin the serialized JSON output in the event that the value of the field isNone.The decorator may be applied without arguments, in which case the fieldwill not be renamed and nulls will be serialized. Note that the propertydecorator must be called as a constructor, i.e. using empty parens `()'@json_property()# HackingSerializing properties as collections, maybe extend this to (gasp) xml.Take a look at serialization properties in c# for more.# Todo
Package: json-protobuf
json-protobuf provides a Json interface to Google'sProtocol Bufferscompiled in C++ code.
The idea is that you can convert a protocol buffer object to a json representation which can be used in API:s.Producing Codejson-protobuf provides a plugin for theprotocprotocol buffer compiler (it ships with protocol buffers). This plugin tellsprotocto produce a set of C++ output files, which define the JSON interface to protocol buffers using the json-spirit library (other libraries will/coul be supported).First, obtain a copy of json-protobuf:$ git clone git@github.com:mickem/json-protobuf.git
$ cd json-protobufNext, install json-protobuf:$ python setup.py installFinally, launch protoc and tell it to produce Lua output:$ protoc -I/path/to/your/proto/files --json_out=/output/path file1.proto file2.protoYou simply need to add--json_outto the arguments toprotocto get it to produce the Json output files.Under the hood,protocis looking for the programprotoc-gen-jsonsomewhere in your $PATH. You can modify $PATH in lieux of installing the package, if you desire.Compiling Produced FilesYou should be able to compile the produced .h and .cc files like you would for protocol buffer output files. If you have an existing Makefile, project, etc, just add the produced .h and .cc files to it.
Package: jsonproxy
Gateway interface between non-standard types andJSONserialization.RequirementsRequirements:python 2.6+UsageYou can add custom types to the JSON serializer proxy by adding them to the
defaultENCODERorDECODERinstances:>>> from jsonproxy import ENCODER, DECODER, dumps, loads
>>> class Point(object):
...     def __init__(self, x, y):
...         self.x = x
...         self.y = y
...     def __repr__(self):
...         return '<Point x=%d, y=%d>' % (self.x, self.y)
...
>>> ENCODER.register('point',
...     lambda obj: isinstance(obj, Point),
...     lambda obj: [obj.x, obj.y])
...
>>> DECODER.register('point',
...     lambda obj: Point(obj[0], obj[1]))
...
>>> test = dumps(Point(23, 42))
>>> print test
{"__proxy__": "point", "value": [23, 42]}
>>> print repr(loads(test))
<Point x=23, y=42>Supported TypesThe following non-standard types are supported:complex (numbers)Ellipsissetdatetime.date objectsdatetime.datetime objectsCreditsTheiso8601.pymodule is written bymicktwomey.BugsUse the issue-tracker athttps://github.com/tehmaze/jsonproxy/issuesLicenseCopyright (c) 2011Wijnand Modderman-LenstraPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.