Questions tagged [ujson]

UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.

Ultra fast JSON encoder and decoder for Python

UltraJSON is an ultra fast JSON encoder and decoder written in pure C with bindings for Python 2.5+ and 3.

For a more painless day to day C/C++ JSON decoder experience please checkout ujson4c, based on UltraJSON.

Please checkout the rest of the projects in the Ultra series: http://github.com/esnme/ultramemcache http://github.com/esnme/ultramysql

To install it just run Pip as usual:

$ pip install ujson

Usage

May be used as a drop in replacement for most other JSON parsers for Python

Source

46 questions
6
votes
3 answers

fastest way to python dict to json binary string

I need to convert this python dict into binary json d = {'1': 'myval', '2': 'myval2'} json_binary_str = b'{"1": "myval", "2": "myval2"}' in python 3, I have this : import ujson ujson.dumps(d) but, this does not create binary…
tensor
  • 3,088
  • 8
  • 37
  • 71
6
votes
1 answer

python No module named ujson, while it's already installed

I've installed ujson using command pip install ujson and when I've tried to run my python project it returns ImportError: No module named ujson OS version: Red Hat Enterprise Linux Server release 7.2 (Maipo) Python version: Python 2.7.6 pip list:…
Amjad Omari
  • 1,104
  • 3
  • 15
  • 40
5
votes
1 answer

ujson can not encode numpy array

numpy array x = np.array([1,2,3,4]) ujson.encode ujson.encode(x, ensure_ascii=False, double_precision=-1) gives me error OverflowError: Maximum recursion level reached version info ujson 1.33 python 3.4.3 It seems to be that ujson can not encode…
Hello lad
  • 17,344
  • 46
  • 127
  • 200
4
votes
3 answers

Wrong architecture issue on virtual environment Apple M1 Chip

I have been trying to run my django project on my new macbook Apple M1 Chip machine but only to encounter the error below. I have tried to ensure that arch command returns i386 on both pycharm and system terminal but still not working. ImportError:…
Harman Kibue
  • 86
  • 1
  • 5
4
votes
1 answer

How can I use ujson as a Flask encoder/decoder?

I have seen that once can use simplejson as a JSON encoder / decoder within a Flask application like this: from simplejson import JSONEncoder, JSONDecoder app.json_encoder = JSONEncoder app.json_decoder = JSONDecoder But ujson does not have such…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
4
votes
2 answers

AWS Lambda -- Unable to import srsly.ujson.ujson for SpaCy

I am trying to add SpaCy as a dependency to my Python Lambda. I am doing this by installing SpaCy as a standalone dependency inside a directory named dependencies using pip3 install spacy --no-deps -t . This is because I can't load the entire Spacy…
4
votes
1 answer

Manipulate JSON without deserializing it

An aiohttp application fetches a JSON from external resource and need to use it to perform another request passing the JSON as the request body. To avoid serialization/deserialization overhead ujson is used and then the JSON object is just passed to…
Rodrigo Oliveira
  • 1,452
  • 4
  • 19
  • 36
4
votes
3 answers

I want to keep order of OrderedDict with ujson

My function's return value type is OrderedDict, and now I want to write this on the file: Here's my code: mainDict = OrderedDict([('a',1),('b',2),('c',3),('d',[4,5,6])]) with open(outFileName, 'w', encoding='utf-8') as outFile : …
sh kim
  • 183
  • 1
  • 8
3
votes
2 answers

Issue in installing ujson in ubuntu

I am trying to install ujson which is required dependency for the installation of RASA. The command I triggered is follows: sudo pip3 install ujson And got the following error message. WARNING: The directory '/home/kamaldeep/.cache/pip' or its…
3
votes
0 answers

Python Max Recursion Reached with ujson, not cPickle

When comparing ujson and cpickle for serializing objects in Python 2.7, why does using ujson as shown gives an error OverflowError: Maximum recursion level reached? import ujson as json sys.setrecursionlimit(10000) with open(myPath, 'w') as fp: …
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
2
votes
0 answers

Deploying python kivy app to android that uses spacy fails with error "ujson.so" is 64-bit instead of 32-bit"

I am building my first kivy application for android. I want to include 'spacy' for natural language processing. Looks like importing spacy is dependent on 'ujson' and any app I build that imports spacy and requires 'ujson' fails with the…
steve
  • 21
  • 1
2
votes
1 answer

Docker image with Sanic over alpine:latest(3.9) uses python json instead of ujson

Dockerfile: FROM alpine:latest RUN apk add --no-cache python3 \ && python3 -m ensurepip \ && rm -r /usr/lib/python*/ensurepip \ && pip3 install -U pip setuptools ez_setup \ && rm -r /root/.cache/* \ && apk add --no-cache gcc…
magic_turn
  • 25
  • 7
2
votes
2 answers

Python breaks parsing json with characters \"

I'm trying to parse json string with an escape character (Of some sort I guess) { "publisher": "\"O'Reilly Media, Inc.\"" } Parser parses well if I remove the character \" from the string, the exceptions raised by different parsers are, json …
All Іѕ Vаиітy
  • 24,861
  • 16
  • 87
  • 111
1
vote
1 answer

accessing ujson content using ESP32

There is a file dumped using ujson. It contains a list of dictionaries. When I try to load it again using ujson it throws an error - ValueError: syntax error in JSON What am I missing if you can explain? I am running it on ESP32 using Thonny and I…
24beads
  • 161
  • 1
  • 2
  • 9
1
vote
1 answer

ujson behaving weirdly during the installation of spacy_readability

I've had difficulty installing spacy_readability which seems to be caused by an old version of ujson. So I have installed the latest version of ujson: !pip install --upgrade ujson --user Requirement already satisfied: ujson in c:\users\desktop…
Abijah
  • 512
  • 4
  • 17
1
2 3 4