{ "info": { "author": "caiyunapp", "author_email": "admin@caiyunapp.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: C", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "

\nnujson: The UltraJSON Fork That Support Numpy Serialization\n

\n\n
\n\n*Inspired by [Pandas' ujson](https://github.com/pandas-dev/pandas/tree/master/pandas/_libs/src/ujson/python)*\n\n[![Build Status](https://travis-ci.org/caiyunapp/ultrajson.svg?branch=master)](https://travis-ci.org/caiyunapp/ultrajson)\n[![](https://img.shields.io/pypi/v/nujson.svg)]()\n\n\n
\n\n- [How to install](#how-to-install)\n- [Example](#example)\n- [Why make such a package and what is modified](#why-make-such-a-package-and-what-is-modified)\n\n# How to install\n\nPython version: Python2.7, Python3.5+\n\nUsing pip:\n\n```sh\npip install -e git+https://github.com/caiyunapp/ultrajson.git#egg=nujson\n```\n\nClone and install:\n\n```sh\n# git clone\ngit clone https://github.com/caiyunapp/ultrajson\n\n# Don't use `python setup.py install`\n# NumPy will install automatically\npip install -e .\n```\n\n\nIf get error like this:\n\n```\nERROR: Could not find a version that satisfies the requirement numpy>=1.16.4 (from nujson) (from versions: 1.9.3)\nERROR: No matching distribution found for numpy>=1.16.4 (from nujson)\n```\n\nTry this:\n\n```sh\npip uninstall numpy\npip install numpy==1.16.4\npip install nujson\n```\n\n# Example\n\n```python\n>>> import numpy as np\n>>> import nujson as ujson\n>>> a = {\"a\": np.int64(100)}\n>>> ujson.dumps(a)\n'{\"a\":100}'\n>>> a[\"b\"] = np.float64(10.9)\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9}'\n>>> a[\"c\"] = np.str_(\"12\")\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9,\"c\":\"12\"}'\n>>> a[\"d\"] = np.array(list(range(10)))\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9,\"c\":\"12\",\"d\":[0,1,2,3,4,5,6,7,8,9]}'\n>>> a[\"e\"] = np.repeat(3.9, 4)\n>>> ujson.dumps(a)\n'{\"a\":100,\"b\":10.9,\"c\":\"12\",\"d\":[0,1,2,3,4,5,6,7,8,9],\"e\":[3.9,3.9,3.9,3.9]}'\n```\n\n# Why make such a package and what is modified\n\nOn Python3, some data types of NumPy is not serializable. Here is some references we searched:\n\n- [python - Why are some numpy datatypes JSON serializable and others not? - Stack Overflow](https://stackoverflow.com/questions/44459168/why-are-some-numpy-datatypes-json-serializable-and-others-not)\n- [Maximum recursion level reached in Python 3 \u00b7 Issue #221 \u00b7 esnme/ultrajson](https://github.com/esnme/ultrajson/issues/221)\n- [Issue 24313: json fails to serialise numpy.int64 - Python tracker](https://bugs.python.org/issue24313)\n\nOne solution is type conversion like: `int(numpy.int64)` and `numpy.array.tolist()`.\nBut it's not good for performance. After searching Internet, find a no longer maintained project [Komnomnomnom/ultrajson](https://github.com/Komnomnomnom/ultrajson) recommond to use [Pandas' ujson](https://github.com/pandas-dev/pandas/tree/master/pandas/_libs/src/ujson/python).\n\nWe tried but found Pandas is to heavy for our projects. So we decide to build our own light weight fork. Currentltly, the esn's ujson master branch has some problems we need to solve, and the `master` branch is based on the [the v1.35 ujson](https://github.com/esnme/ultrajson/releases/tag/v1.35).\n\nThe main point is convert NumPy data type in C, with calling NumPy's header. [Commit 187bd15](https://github.com/caiyunapp/ultrajson/commit/187bd155b7acd303aa6f5571f5b858c0d244edd6) has the most changes we made to support NumPy, and [Commit afedc42](https://github.com/caiyunapp/ultrajson/commit/afedc42b2ce288064821981acd70592342da55fa) fix a build issue on macOS caused by Clang.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "http://github.com/caiyunapp/ultrajson", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://caiyunapp.com", "keywords": "numpy ujson json python3", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "nujson", "package_url": "https://pypi.org/project/nujson/", "platform": "any", "project_url": "https://pypi.org/project/nujson/", "project_urls": { "Download": "http://github.com/caiyunapp/ultrajson", "Homepage": "https://caiyunapp.com", "Source": "http://github.com/caiyunapp/ultrajson" }, "release_url": "https://pypi.org/project/nujson/1.35/", "requires_dist": null, "requires_python": "", "summary": "Ultra fast JSON encoder and decoder for Python with NumPy support", "version": "1.35" }, "last_serial": 5581049, "releases": { "1.35": [ { "comment_text": "", "digests": { "md5": "acc555f3746f815a4eda1e7e46b36859", "sha256": "04c68880a06c34a966e294d4f4d5432e3d8e3000a1b28ae800c332112f77297b" }, "downloads": -1, "filename": "nujson-1.35.tar.gz", "has_sig": false, "md5_digest": "acc555f3746f815a4eda1e7e46b36859", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 187249, "upload_time": "2019-07-25T03:50:03", "url": "https://files.pythonhosted.org/packages/19/87/573272b835926ecc56cf771ecd4440ee54dcd3e384c783782e9ed47f336c/nujson-1.35.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "acc555f3746f815a4eda1e7e46b36859", "sha256": "04c68880a06c34a966e294d4f4d5432e3d8e3000a1b28ae800c332112f77297b" }, "downloads": -1, "filename": "nujson-1.35.tar.gz", "has_sig": false, "md5_digest": "acc555f3746f815a4eda1e7e46b36859", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 187249, "upload_time": "2019-07-25T03:50:03", "url": "https://files.pythonhosted.org/packages/19/87/573272b835926ecc56cf771ecd4440ee54dcd3e384c783782e9ed47f336c/nujson-1.35.tar.gz" } ] }