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

126 Commits

Author SHA1 Message Date
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
Tim Dawborn
948807cfe5
Correct JSON decoding implementation to die on trailing commas in Objects. Fixes esnme/ultrajson#50. 2018-12-10 18:01:40 +11: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
markpiekarz
629128de5e Update ultrajsondec.c
Explicitly include stdint.h to define SIZE_MAX.
2017-03-29 17:02:31 +11: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
870ee48fe1 Fixes for sort_keys bug and a typo.
- Fixed segfault when using sort_keys=True on dict with unorderable keys (GH247)

    - Fixed refcount becoming negative when using sort_keys=True (GH243)

    - Fixed compile error when defining JSON_NO_EXTRA_WHITESPACE
      caused by a wrongly named variable. (GH245)
2017-02-04 01:07:52 +01:00
Joakim Hamrén
ab6b6f88cd Merge pull request #217 from orivej/indent-dict-values
Indent dict values
2016-10-10 22:25:22 +02:00
Joakim Hamrén
d25e024f48 Merge pull request #238 from WGH-/static-functions
added "static" to C functions, where possible
2016-10-10 22:06:20 +02:00
Joakim Hamren
6a0d07a7df Indentation fixes and other style fixes 2016-10-10 21:50:57 +02:00
WGH
6cf6c7ff25 added "static" to C functions, where possible
1. It reduces clutter in symbol table.
2. It fixes issues with C99 inline semantics for functions
   marked as inline (#237, #180, #222), which manifests
   when compiled with GCC>=5.
2016-08-27 17:34:22 +03:00
Orivej Desh
11b0d2db25 Indent dict values 2016-04-03 16:30:43 +00:00
Joakim Hamren
01cb24910e Merge branch 'correct_unit_tests_and_benchmarks' of https://github.com/timdawborn/ultrajson into timdawborn-correct_unit_tests_and_benchmarks
Conflicts:
	tests/tests.py
2016-01-18 06:20:14 +01: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 Hamrén
06fe4c68f0 Merge pull request #186 from shashurup/master
escape_forward_slashes now only ignores forward slashes, not everythi…
2016-01-15 03:50:42 +01:00
Tim Dawborn
04428508d6 * Refactored the unit testing and benchmarking code to work natively under
both Python 2 and Python 3, removing the need for 2to3 to be run. This
  indirectly fixes #177.
* Corrected a duplicate-named method in the unit testing code. Corrected the
  now-exposed broken logic that wasn't being tested. This was
  highlighted in #186 but the author did not appear to realise that the
  method name was being masked in the unit test class.
* Corrected the test case skipping logic to use unittest.skipIf instead
  of just returning from the method upon an ImportError so that the skip
  can actually be registered as a skipped test instead of a passed test.
* Updated the tests to additionally run on Python 3.5 on Travis. This
  covers #195.
* Merged the two benchmarking files into one, and modularised the code.
  Also added native RST output so the benchmarking results can be placed
  directly into the README file.
2015-12-29 14:23:23 +11:00
Joakim Hamren
0c52200eb4 Removed a left-over from conflict resolution. 2015-11-30 11:58:32 +01:00
Georgy Kibardin
457cda771d escape_forward_slashes now only ignores forward slashes, not everything else 2015-09-08 15:54:13 +03: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
Joakim Hamrén
c9744834ab Merge pull request #142 from kevinbirch/support_unsigned_long_numerics
Support values between [0, 2^64 - 1]
2014-11-14 00:33:20 +01:00
kevin birch
cbd68782c8 add encoding support for unsigned long long 2014-11-11 18:25:27 -05:00
Jonas Tärnström
0a2933f74f Merge pull request #148 from Jahaja/fix
Fix to avoid a crash on bounds-check fail
2014-10-29 11:18:27 +01:00
Joakim Hamren
7d28dc09ec Fixed segfault on invalid unicode char on python 3 2014-10-28 23:32:14 +01:00
Joakim Hamren
1af8acdd10 Fix to avoid a crash on bounds-check fail 2014-10-28 23:30:00 +01: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
23c154f798 Replaced UINT_MAX with SIZE_MAX as a better bound check for wrapping memory allocation sizes when escaping strings 2014-04-14 13:39:01 +02:00
Romulo A. Ceccon
c2ca24f516 Remove unused function ClearError() 2013-09-26 17:20:59 -03:00
smartsgy
9de9190859 Fix minGW sprintf_s build error
On windows, We should replace snprintf on msvc only.
2013-09-01 22:54:57 +08:00
Kieran O'Mahony
ce308a1917 Fix invalid memory read (from valgrind) during test_decodeBrokenListLeakTest 2013-06-19 18:41:18 +01:00
Jonas Tarnstrom
08ff81a21d Added explanation text 2013-06-11 08:10:34 +02:00
Jonas Tarnstrom
4e4dc5e4cc Added 2 bytes to the string reservation macro to guaranteed to able to hold the quotes 2013-06-11 08:09:57 +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
Jonas Tarnstrom
96dda4e32d Fixed C89 build issue in Win32 2013-06-10 12:14:23 +02:00
Jonas Tarnstrom
79ac0e971d Fixed potential overflow issue with the estimations of string buffer lengths 2013-06-10 12:14:09 +02:00
Mikhail Sychev
6f731e94d1 Use uint32 for decoding depth counter. 2013-05-17 16:43:14 -07:00
Mikhail Sychev
d194048164 Decoding depth limitation/SIGSEGV fix 2013-05-17 16:21:43 -07:00
Mikhail Sychev
fbf3f96a5d Removed intValue negative value checks as intValue is declared as JSUINT64. 2013-05-16 13:42:54 -07:00
Mikhail Sychev
0acd21cb84 Added memory (re)allocation checks.
- Guards against memory alloc size overflow.
 - Memory leak on failed reallocation.
2013-05-14 15:54:35 -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
unknown
627926af67 Fixed issue with decoding long decimal numbers 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
unknown
42e7d1d9da Hopefully fixed integer and double decoding capabilities to match those of the old decoder 2013-01-18 16:17:47 +01:00
unknown
a2e9adb885 Updated license preamble 2013-01-16 16:22:08 +01:00
unknown
a92339d065 Minor code cleanup and speed optimizations 2013-01-08 10:38:24 +01:00
unknown
8d3b807713 Code cleanup 2013-01-07 18:30:18 +01:00
unknown
aee46fa31e Cleanup and final fixes of new numeric decoder 2013-01-07 18:27:55 +01:00
unknown
0b1fc32ca2 Initial commit of new numeric decoder 2013-01-07 17:19:53 +01:00
unknown
9bdde8d8e8 Improved double decoding performance and added additional tests 2012-12-17 15:27:19 +01:00
unknown
6d6c8a87d2 Fixed error message being overwritten with incorrect one when decoding overlong integers in an array 2012-12-17 14:50:14 +01:00
Jonas Tarnstrom
a1747b95c6 Fixed all compilers warnings on Level4 MSVC++ 2012-11-13 17:14:09 +01:00
Logan Zhou
33d4bce052 Removed duplicated function. Added test for trailing whitespaces/non-whitespaces. 2012-10-17 16:19:51 +08:00
Logan Zhou
8bda5ad8de Auto skip trailing whitespace and carriage return, instead of raising 'ValueError: Trailing data'. 2012-10-17 12:55:45 +08:00
Jonas Tarnstrom
b7bdaa8cd7 Added ValueError exception to decoder when values are too big 2012-09-24 17:20:11 +02:00
Jonas Tarnstrom
49aa2c8e56 Decoder now properly handles detection of trailing commas in arrays and trailing data at end of input 2012-08-14 11:24:08 +02:00
Jonas Tarnstrom
a6af1d09c6 Updated license to 3-clause BSD 2012-06-25 11:29:54 +02:00
Kieran O'Mahony
6901f41a7c memory alignment fixes
Avoids segmentation faults on strict architectures e.g. SPARC
2012-06-12 12:05:00 +01:00
Kieran O'Mahony
c4016cfcda don't compare pointers outside their allocated regions (fixes segmentation faults) 2012-06-12 12:05:00 +01:00
Kieran O'Mahony
3998aa86eb check if malloc succeeds to avoid segmentation faults when ujson runs out of memory 2012-06-12 12:04:59 +01:00
Kieran O'Mahony
9ffbfd45b5 remove troublesome typedef
Will not build with some versions of mingw and not really used anymore
anyway.
2012-06-12 12:04:59 +01:00
Kieran O'Mahony
fda0329ca9 msvc build fixes 2012-06-12 12:04:59 +01:00
Kieran O'Mahony
a1fd2a582a increased double precision 2012-06-12 12:04:59 +01:00
Kieran O'Mahony
79e980641d fix compiler warnings
& remove redundant enum
2012-06-12 12:04:59 +01:00
Kieran O'Mahony
d041aba16a tabs -> spaces, convert newlines 2012-06-12 12:04:59 +01:00
Jonas Trnstrm
fd13812388 Minor optimizations using local variables 2012-04-22 13:06:40 +02:00
unknown
83f1ee99f7 Restructured code for better pypi packaging 2012-02-07 17:11:29 +01:00