1
0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-12-04 06:38:23 +01:00
Commit Graph

59 Commits

Author SHA1 Message Date
Dimitri Papadopoulos Orfanos
b7a4dfda0a
Fix typos found by codespell (#610) 2023-10-17 18:45:44 +01:00
JustAnotherArchivist
8a946e5830 Add separators encoding parameter
Closes #283
2022-07-11 00:43:29 +01:00
JustAnotherArchivist
bc7bdff051 Replace wchar_t string decoding implementation with a uint32_t-based one
This fixes character handling on platforms with 16-bit wchar_t (notably, Windows), which was broken (in different ways) on both CPython and PyPy.

Fixes #552
2022-06-19 23:11:17 +00:00
JustAnotherArchivist
aa068e335f Add support for arbitrary size integers 2022-06-16 17:26:19 +00:00
JustAnotherArchivist
9b9af1ab70 Fix handling of surrogates on encoding
This allows surrogates anywhere in the input, compatible with the json module from the standard library.

This also refactors two interfaces:
- The `PyUnicode` to `char*` conversion is moved into its own function, separated from the `JSONTypeContext` handling, so it can be reused for other things in the future (e.g. indentation and separators) which don't have a type context.
- Converting the `char*` output to a Python string with surrogates intact requires the string length for `PyUnicode_Decode` & Co. While `strlen` could be used, the length is already known inside the encoder, so the encoder function now also takes an extra `size_t` pointer argument to return that and no longer NUL-terminates the string. This also permits output that contains NUL bytes (even though that would be invalid JSON), e.g. if an object's `__json__` method return value were to contain them.

Fixes #156
Fixes #447
Fixes #537
Supersedes #284
2022-05-30 01:58:12 +00:00
Brénainn Woodsend
1a39406b3a Remove the hidden JSON_NO_EXTRA_WHITESPACE compile knob.
Unsetting it can lead to seg-faults. I don't think it's worth having to fix and
then test this undocumented permutation.
2022-04-05 21:04:39 +01:00
joncrall
13aa30e152
Fix nan bug in pandas port 2022-04-04 13:56:19 -04:00
joncrall
f090103b31
NaN and Inf in loads - Port of Pandas #30295 2022-04-04 13:56:11 -04:00
JustAnotherArchivist
f9aa23b5e6 Remove dead code that used to handle the separate int type in Python 2 2022-02-20 10:59:11 +00:00
Dr. Nick
e00caaebd5 dconv no longer uses global instances of StringToDoubleConverter/DoubleToStringConverter 2021-08-03 10:17:10 -04:00
David W.H. Swenson
954a9a0a00
cleanup 2020-11-11 16:54:57 +01:00
David W.H. Swenson
a48f8b22f1
Set same bounds as std lib for negative exponent 2020-11-11 16:41:34 +01:00
David W.H. Swenson
af699c3cd0
Match Python json output for exponents 2020-11-11 14:41:51 +01:00
Hugo
5f1e8479fa Lint trailing-whitespace 2020-05-12 09:21:45 +03:00
Eric Le Lay
e0c113e6a2 Merge branch 'master' into 264-reject_bytes 2020-05-08 17:34:35 +02:00
Hugo van Kemenade
f953a0978a
Update comment 2020-05-04 09:23:39 +03:00
Hugo van Kemenade
d9ca1c9b5b
Merge branch 'master' into add_nan_support 2020-03-27 21:41:33 +02:00
Hugo
61453ad7fd Fix typo 2020-03-08 00:17:27 +02:00
Hugo
c810a5b8a6 Also define LIKELY/UNLIKELY for _WIN32 2020-03-08 00:17:27 +02:00
Hugo
75695ba61e Indent ifdefs 2020-03-08 00:17:27 +02:00
Natanael Copa
0f52df8f9b Reduce default buffer on stack size
Fix segfaults on musl libc when ultrajson runs in a thread. On musl libc
the default thread stack size is only 80k so allocating a 128k buffer on
stack will guarantee a crash. There seems not to be any evident
performance benefit using big buffer on stack either so we just reduce
the default.

fixes #254
2020-03-02 23:45:56 +02:00
Eric Le Lay
b69b37f6d0
fix typo in doc (2)
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-03-01 15:53:43 +01:00
Hugo van Kemenade
631850788d
Merge branch 'master' into add_nan_support 2020-02-25 22:34:37 +02:00
Hugo van Kemenade
1588690257
Merge branch 'master' into 264-reject_bytes 2020-02-25 22:28:14 +02:00
Hugo
d53480c332 http -> https 2020-02-18 21:57:13 +02:00
Mark Guzman
fe0e88d345
adding an allow_nan keyword argument to dumps defaulted to True
with this ujson matches the builtin json behavior for NaN and Inf.
if a user wants to retain the old behavior they can pass allow_nan=False
to ensure strict json compatibility.
2019-02-20 09:50:05 -05:00
Eric Le Lay
ad280fd99e new reject_bytes option to raise on bytes
raise TypeError when encountering bytes in ujson.dumps() to prevent
unexpected Unicode exceptions in production.
Fixes #264
2017-06-11 11:58:10 +02:00
Joakim Hamren
eb7d894f22 Integrated google's double-conversion lib
To fix issues with floating-point precision we've made use of Google's
double-conversion lib to handle conversions of doubles to and from strings.

In addition to fixing our precision problems this will improve double
encoding by 4-5x. Decoding is however slightly slower according to the
benchmarks - but accurate at least.

This change removes the double_precision encoding option and the
precise_float decoding option.
2017-02-14 12:20:04 +01:00
Joakim Hamren
ac4637fbc4 Following std json handling of None dict key
Previously a None dict item key would be outputted in JSON as "None".
To better align with the standard json module this was changed to output
"null". There's no proper representation of null object keys in JSON so
this is implementation specific but it seems more natural to follow
suit when it can be done without a significant performance hit.

Added and used branch prediction macros (LIKELY/UNLIKELY) as well.
2017-02-04 16:36:14 +01:00
Joakim Hamren
6a0d07a7df Indentation fixes and other style fixes 2016-10-10 21:50:57 +02:00
Joakim Hamrén
86bb8ffd10 Merge pull request #157 from wlanslovenija/raw-json
If an object has a __json__ method, use it when encoding
2016-01-15 05:06:19 +01:00
Joakim Hamren
0c52200eb4 Removed a left-over from conflict resolution. 2015-11-30 11:58:32 +01:00
Chris Huang
930dfa5525 Support for space indent for JSON encoding 2015-04-09 12:30:46 +02:00
Tim Dawborn
921716a3b7 Initial support for sort_keys parameter for JSON encoding. 2015-04-08 20:42:56 +02:00
Mathieu Leplatre
d169b7ccbc Add option to disable forward slash escape
Ref issue #144
2015-03-31 23:41:51 +02:00
Mitar
a8f0f0f101 If an object has a __json__ method, use it when encoding.
It should return a raw JSON string which will be directly included in
the resulting JSON when encoding.
2014-12-29 10:13:46 +01:00
kevin birch
cbd68782c8 add encoding support for unsigned long long 2014-11-11 18:25:27 -05:00
kevin birch
6430079c3d support promotion of numeric values to unsigned long 2014-09-02 17:00:16 -04:00
Jonas Tarnstrom
0d76bd0849 Revert "Minor performance optimization"
This reverts commit 510a8fc6d7fd2af9fd39970ff3de4d9aac382706.
2014-04-16 08:42:48 +02:00
Jonas Tarnstrom
510a8fc6d7 Minor performance optimization 2014-04-14 15:52:22 +02:00
Jonas Tarnstrom
4057771d9c Added private argument support for encoder path 2014-04-14 14:43:15 +02:00
Jonas Tarnstrom
9f3449b826 Updated copyright clause 2014-04-14 13:45:50 +02:00
Jonas Tarnstrom
06173a7354 Improved generic iterator support, revmoed iterBegin from encoder API, added test for blist 2014-04-14 13:39:03 +02:00
Jonas Tarnstrom
4073babe2c Merged (line-by-line prv pointer additions from ujson4c project. Bumped version 2013-06-10 12:44:04 +02:00
Mikhail Sychev
d194048164 Decoding depth limitation/SIGSEGV fix 2013-05-17 16:21:43 -07:00
Mikhail Sychev
82861c94d5 Build file improvements.
- Do no redeclare endianness if it's already defined.
 - Do not declare FASTCALL_ATTR on x86_64 as it's not required(used anyway under the hood).
2013-05-10 16:56:30 -07:00
Mikhail Sychev
e098bd1ce9 Fixed style of .c and .h files to use 2 spaces instead of 4 spaces and tabs and added some braces for easier code reading. 2013-05-08 13:52:53 -07:00
jtarnstrom
fd6cc28ab9 Added support for python decimal. Forward ported encode_html_chars patch. Made it all into one big nice commit 2013-02-12 17:15:42 +01:00
jtarnstrom
c5c3c7fbbc Added precise_float directive to make decoder use more precise but slower strtod for double decoding instead of built-in faster functions 2013-02-12 17:15:41 +01:00
fcicq
c92decd12f Change u_int*_t to uint*_t, fix https://github.com/esnme/ultrajson/issues/72
uint*_t is defined in stdint.h, rebase the two commits into one.
2013-01-23 22:45:07 +08:00