├── .appveyor.yml ├── .dockerignore ├── .editorconfig ├── .github └── workflows │ └── integration.yml ├── .gitignore ├── CMakeLists.txt ├── CREDITS ├── LICENSE ├── README.md ├── benchmark ├── README.md ├── benchmark.php ├── composer.json └── phpbench │ ├── DecodeBench.php │ ├── KeyValueBench.php │ ├── MultipleAccessBench.php │ └── SingleCharStringsBench.php ├── config.m4 ├── config.w32 ├── docker_php7.1-alpine ├── docker_php7.2-alpine ├── docker_php7.3-alpine ├── docker_php7.4-alpine ├── docker_php8.0-alpine ├── docker_php8.1-alpine ├── docker_php8.2-alpine ├── jsonexamples ├── apache_builds.json ├── canada.json ├── citm_catalog.json ├── github_events.json ├── gsoc-2018.json ├── instruments.json ├── marine_ik.json ├── mesh.json ├── mesh.pretty.json ├── numbers.json ├── random.json ├── small │ ├── adversarial.json │ ├── demo.json │ ├── flatadversarial.json │ ├── jsoniter_scala │ │ ├── README.md │ │ ├── che-1.geo.json │ │ ├── che-2.geo.json │ │ ├── che-3.geo.json │ │ ├── google_maps_api_compact_response.json │ │ ├── google_maps_api_response.json │ │ ├── twitter_api_compact_response.json │ │ └── twitter_api_response.json │ ├── repeat.json │ ├── truenull.json │ └── twitter_timeline.json ├── stringifiedphp.json ├── test_parsing │ ├── i_number_double_huge_neg_exp.json │ ├── i_number_huge_exp.json │ ├── i_number_neg_int_huge_exp.json │ ├── i_number_pos_double_huge_exp.json │ ├── i_number_real_neg_overflow.json │ ├── i_number_real_pos_overflow.json │ ├── i_number_real_underflow.json │ ├── i_number_too_big_neg_int.json │ ├── i_number_too_big_pos_int.json │ ├── i_number_very_big_negative_int.json │ ├── i_object_key_lone_2nd_surrogate.json │ ├── i_string_1st_surrogate_but_2nd_missing.json │ ├── i_string_1st_valid_surrogate_2nd_invalid.json │ ├── i_string_UTF-16LE_with_BOM.json │ ├── i_string_UTF-8_invalid_sequence.json │ ├── i_string_UTF8_surrogate_U+D800.json │ ├── i_string_incomplete_surrogate_and_escape_valid.json │ ├── i_string_incomplete_surrogate_pair.json │ ├── i_string_incomplete_surrogates_escape_valid.json │ ├── i_string_invalid_lonely_surrogate.json │ ├── i_string_invalid_surrogate.json │ ├── i_string_invalid_utf-8.json │ ├── i_string_inverted_surrogates_U+1D11E.json │ ├── i_string_iso_latin_1.json │ ├── i_string_lone_second_surrogate.json │ ├── i_string_lone_utf8_continuation_byte.json │ ├── i_string_not_in_unicode_range.json │ ├── i_string_overlong_sequence_2_bytes.json │ ├── i_string_overlong_sequence_6_bytes.json │ ├── i_string_overlong_sequence_6_bytes_null.json │ ├── i_string_truncated-utf-8.json │ ├── i_string_utf16BE_no_BOM.json │ ├── i_string_utf16LE_no_BOM.json │ ├── i_structure_500_nested_arrays.json │ ├── i_structure_UTF-8_BOM_empty_object.json │ ├── n_array_1_true_without_comma.json │ ├── n_array_a_invalid_utf8.json │ ├── n_array_colon_instead_of_comma.json │ ├── n_array_comma_after_close.json │ ├── n_array_comma_and_number.json │ ├── n_array_double_comma.json │ ├── n_array_double_extra_comma.json │ ├── n_array_extra_close.json │ ├── n_array_extra_comma.json │ ├── n_array_incomplete.json │ ├── n_array_incomplete_invalid_value.json │ ├── n_array_inner_array_no_comma.json │ ├── n_array_invalid_utf8.json │ ├── n_array_items_separated_by_semicolon.json │ ├── n_array_just_comma.json │ ├── n_array_just_minus.json │ ├── n_array_missing_value.json │ ├── n_array_newlines_unclosed.json │ ├── n_array_number_and_comma.json │ ├── n_array_number_and_several_commas.json │ ├── n_array_spaces_vertical_tab_formfeed.json │ ├── n_array_star_inside.json │ ├── n_array_unclosed.json │ ├── n_array_unclosed_trailing_comma.json │ ├── n_array_unclosed_with_new_lines.json │ ├── n_array_unclosed_with_object_inside.json │ ├── n_incomplete_false.json │ ├── n_incomplete_null.json │ ├── n_incomplete_true.json │ ├── n_multidigit_number_then_00.json │ ├── n_number_++.json │ ├── n_number_+1.json │ ├── n_number_+Inf.json │ ├── n_number_-01.json │ ├── n_number_-1.0..json │ ├── n_number_-2..json │ ├── n_number_-NaN.json │ ├── n_number_.-1.json │ ├── n_number_.2e-3.json │ ├── n_number_0.1.2.json │ ├── n_number_0.3e+.json │ ├── n_number_0.3e.json │ ├── n_number_0.e1.json │ ├── n_number_0_capital_E+.json │ ├── n_number_0_capital_E.json │ ├── n_number_0e+.json │ ├── n_number_0e.json │ ├── n_number_1.0e+.json │ ├── n_number_1.0e-.json │ ├── n_number_1.0e.json │ ├── n_number_1_000.json │ ├── n_number_1eE2.json │ ├── n_number_2.e+3.json │ ├── n_number_2.e-3.json │ ├── n_number_2.e3.json │ ├── n_number_9.e+.json │ ├── n_number_Inf.json │ ├── n_number_NaN.json │ ├── n_number_U+FF11_fullwidth_digit_one.json │ ├── n_number_expression.json │ ├── n_number_hex_1_digit.json │ ├── n_number_hex_2_digits.json │ ├── n_number_infinity.json │ ├── n_number_invalid+-.json │ ├── n_number_invalid-negative-real.json │ ├── n_number_invalid-utf-8-in-bigger-int.json │ ├── n_number_invalid-utf-8-in-exponent.json │ ├── n_number_invalid-utf-8-in-int.json │ ├── n_number_minus_infinity.json │ ├── n_number_minus_sign_with_trailing_garbage.json │ ├── n_number_minus_space_1.json │ ├── n_number_neg_int_starting_with_zero.json │ ├── n_number_neg_real_without_int_part.json │ ├── n_number_neg_with_garbage_at_end.json │ ├── n_number_real_garbage_after_e.json │ ├── n_number_real_with_invalid_utf8_after_e.json │ ├── n_number_real_without_fractional_part.json │ ├── n_number_starting_with_dot.json │ ├── n_number_with_alpha.json │ ├── n_number_with_alpha_char.json │ ├── n_number_with_leading_zero.json │ ├── n_object_bad_value.json │ ├── n_object_bracket_key.json │ ├── n_object_comma_instead_of_colon.json │ ├── n_object_double_colon.json │ ├── n_object_emoji.json │ ├── n_object_garbage_at_end.json │ ├── n_object_key_with_single_quotes.json │ ├── n_object_lone_continuation_byte_in_key_and_trailing_comma.json │ ├── n_object_missing_colon.json │ ├── n_object_missing_key.json │ ├── n_object_missing_semicolon.json │ ├── n_object_missing_value.json │ ├── n_object_no-colon.json │ ├── n_object_non_string_key.json │ ├── n_object_non_string_key_but_huge_number_instead.json │ ├── n_object_repeated_null_null.json │ ├── n_object_several_trailing_commas.json │ ├── n_object_single_quote.json │ ├── n_object_trailing_comma.json │ ├── n_object_trailing_comment.json │ ├── n_object_trailing_comment_open.json │ ├── n_object_trailing_comment_slash_open.json │ ├── n_object_trailing_comment_slash_open_incomplete.json │ ├── n_object_two_commas_in_a_row.json │ ├── n_object_unquoted_key.json │ ├── n_object_unterminated-value.json │ ├── n_object_with_single_string.json │ ├── n_object_with_trailing_garbage.json │ ├── n_single_space.json │ ├── n_string_1_surrogate_then_escape.json │ ├── n_string_1_surrogate_then_escape_u.json │ ├── n_string_1_surrogate_then_escape_u1.json │ ├── n_string_1_surrogate_then_escape_u1x.json │ ├── n_string_accentuated_char_no_quotes.json │ ├── n_string_backslash_00.json │ ├── n_string_escape_x.json │ ├── n_string_escaped_backslash_bad.json │ ├── n_string_escaped_ctrl_char_tab.json │ ├── n_string_escaped_emoji.json │ ├── n_string_incomplete_escape.json │ ├── n_string_incomplete_escaped_character.json │ ├── n_string_incomplete_surrogate.json │ ├── n_string_incomplete_surrogate_escape_invalid.json │ ├── n_string_invalid-utf-8-in-escape.json │ ├── n_string_invalid_backslash_esc.json │ ├── n_string_invalid_unicode_escape.json │ ├── n_string_invalid_utf8_after_escape.json │ ├── n_string_leading_uescaped_thinspace.json │ ├── n_string_no_quotes_with_bad_escape.json │ ├── n_string_single_doublequote.json │ ├── n_string_single_quote.json │ ├── n_string_single_string_no_double_quotes.json │ ├── n_string_start_escape_unclosed.json │ ├── n_string_unescaped_crtl_char.json │ ├── n_string_unescaped_newline.json │ ├── n_string_unescaped_tab.json │ ├── n_string_unicode_CapitalU.json │ ├── n_string_with_trailing_garbage.json │ ├── n_structure_100000_opening_arrays.json │ ├── n_structure_U+2060_word_joined.json │ ├── n_structure_UTF8_BOM_no_data.json │ ├── n_structure_angle_bracket_..json │ ├── n_structure_angle_bracket_null.json │ ├── n_structure_array_trailing_garbage.json │ ├── n_structure_array_with_extra_array_close.json │ ├── n_structure_array_with_unclosed_string.json │ ├── n_structure_ascii-unicode-identifier.json │ ├── n_structure_capitalized_True.json │ ├── n_structure_close_unopened_array.json │ ├── n_structure_comma_instead_of_closing_brace.json │ ├── n_structure_double_array.json │ ├── n_structure_end_array.json │ ├── n_structure_incomplete_UTF8_BOM.json │ ├── n_structure_lone-invalid-utf-8.json │ ├── n_structure_lone-open-bracket.json │ ├── n_structure_no_data.json │ ├── n_structure_null-byte-outside-string.json │ ├── n_structure_number_with_trailing_garbage.json │ ├── n_structure_object_followed_by_closing_object.json │ ├── n_structure_object_unclosed_no_value.json │ ├── n_structure_object_with_comment.json │ ├── n_structure_object_with_trailing_garbage.json │ ├── n_structure_open_array_apostrophe.json │ ├── n_structure_open_array_comma.json │ ├── n_structure_open_array_object.json │ ├── n_structure_open_array_open_object.json │ ├── n_structure_open_array_open_string.json │ ├── n_structure_open_array_string.json │ ├── n_structure_open_object.json │ ├── n_structure_open_object_close_array.json │ ├── n_structure_open_object_comma.json │ ├── n_structure_open_object_open_array.json │ ├── n_structure_open_object_open_string.json │ ├── n_structure_open_object_string_with_apostrophes.json │ ├── n_structure_open_open.json │ ├── n_structure_single_eacute.json │ ├── n_structure_single_star.json │ ├── n_structure_trailing_#.json │ ├── n_structure_uescaped_LF_before_string.json │ ├── n_structure_unclosed_array.json │ ├── n_structure_unclosed_array_partial_null.json │ ├── n_structure_unclosed_array_unfinished_false.json │ ├── n_structure_unclosed_array_unfinished_true.json │ ├── n_structure_unclosed_object.json │ ├── n_structure_unicode-identifier.json │ ├── n_structure_whitespace_U+2060_word_joiner.json │ ├── n_structure_whitespace_formfeed.json │ ├── y_array_arraysWithSpaces.json │ ├── y_array_empty-string.json │ ├── y_array_empty.json │ ├── y_array_ending_with_newline.json │ ├── y_array_false.json │ ├── y_array_heterogeneous.json │ ├── y_array_null.json │ ├── y_array_with_1_and_newline.json │ ├── y_array_with_leading_space.json │ ├── y_array_with_several_null.json │ ├── y_array_with_trailing_space.json │ ├── y_number.json │ ├── y_number_0e+1.json │ ├── y_number_0e1.json │ ├── y_number_after_space.json │ ├── y_number_double_close_to_zero.json │ ├── y_number_int_with_exp.json │ ├── y_number_minus_zero.json │ ├── y_number_negative_int.json │ ├── y_number_negative_one.json │ ├── y_number_negative_zero.json │ ├── y_number_real_capital_e.json │ ├── y_number_real_capital_e_neg_exp.json │ ├── y_number_real_capital_e_pos_exp.json │ ├── y_number_real_exponent.json │ ├── y_number_real_fraction_exponent.json │ ├── y_number_real_neg_exp.json │ ├── y_number_real_pos_exponent.json │ ├── y_number_simple_int.json │ ├── y_number_simple_real.json │ ├── y_object.json │ ├── y_object_basic.json │ ├── y_object_duplicated_key.json │ ├── y_object_duplicated_key_and_value.json │ ├── y_object_empty.json │ ├── y_object_empty_key.json │ ├── y_object_escaped_null_in_key.json │ ├── y_object_extreme_numbers.json │ ├── y_object_long_strings.json │ ├── y_object_simple.json │ ├── y_object_string_unicode.json │ ├── y_object_with_newlines.json │ ├── y_string_1_2_3_bytes_UTF-8_sequences.json │ ├── y_string_accepted_surrogate_pair.json │ ├── y_string_accepted_surrogate_pairs.json │ ├── y_string_allowed_escapes.json │ ├── y_string_backslash_and_u_escaped_zero.json │ ├── y_string_backslash_doublequotes.json │ ├── y_string_comments.json │ ├── y_string_double_escape_a.json │ ├── y_string_double_escape_n.json │ ├── y_string_escaped_control_character.json │ ├── y_string_escaped_noncharacter.json │ ├── y_string_in_array.json │ ├── y_string_in_array_with_leading_space.json │ ├── y_string_last_surrogates_1_and_2.json │ ├── y_string_nbsp_uescaped.json │ ├── y_string_nonCharacterInUTF-8_U+10FFFF.json │ ├── y_string_nonCharacterInUTF-8_U+FFFF.json │ ├── y_string_null_escape.json │ ├── y_string_one-byte-utf-8.json │ ├── y_string_pi.json │ ├── y_string_reservedCharacterInUTF-8_U+1BFFF.json │ ├── y_string_simple_ascii.json │ ├── y_string_space.json │ ├── y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json │ ├── y_string_three-byte-utf-8.json │ ├── y_string_two-byte-utf-8.json │ ├── y_string_u+2028_line_sep.json │ ├── y_string_u+2029_par_sep.json │ ├── y_string_uEscape.json │ ├── y_string_uescaped_newline.json │ ├── y_string_unescaped_char_delete.json │ ├── y_string_unicode.json │ ├── y_string_unicodeEscapedBackslash.json │ ├── y_string_unicode_2.json │ ├── y_string_unicode_U+10FFFE_nonchar.json │ ├── y_string_unicode_U+1FFFE_nonchar.json │ ├── y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json │ ├── y_string_unicode_U+2064_invisible_plus.json │ ├── y_string_unicode_U+FDD0_nonchar.json │ ├── y_string_unicode_U+FFFE_nonchar.json │ ├── y_string_unicode_escaped_double_quote.json │ ├── y_string_utf8.json │ ├── y_string_with_del_character.json │ ├── y_structure_lonely_false.json │ ├── y_structure_lonely_int.json │ ├── y_structure_lonely_negative_real.json │ ├── y_structure_lonely_null.json │ ├── y_structure_lonely_string.json │ ├── y_structure_lonely_true.json │ ├── y_structure_string_empty.json │ ├── y_structure_trailing_newline.json │ ├── y_structure_true_in_array.json │ └── y_structure_whitespace_array.json ├── twitter.json ├── twitterescaped.json └── update-center.json ├── package.xml ├── php_simdjson.cpp ├── php_simdjson.h ├── phpbench.json.dist ├── scripts └── compare_decode_results.php ├── simdjson.stub.php ├── simdjson_arginfo.h ├── src ├── simdjson.cpp ├── simdjson.h ├── simdjson_bindings.cpp └── simdjson_bindings_defs.h └── tests ├── 32bit_support.phpt ├── 64bit_support.phpt ├── _files └── result.json ├── compat ├── 001.phpt ├── bug41067.phpt ├── bug41504.phpt ├── bug45791.phpt ├── bug47644.phpt ├── bug50224.phpt ├── bug62010.phpt ├── bug64874_part1.phpt ├── bug64874_part2.phpt ├── bug68546.phpt ├── bug68817.phpt ├── bug68938.phpt ├── bug69187.phpt ├── fail001.phpt ├── json_decode_basic.phpt ├── json_decode_invalid_utf8.phpt ├── pass001.1.phpt ├── pass001.1_64bit.phpt ├── pass001.phpt ├── pass002.phpt └── pass003.phpt ├── decode_args.phpt ├── decode_exception.phpt ├── decode_integer_overflow.phpt ├── decode_invalid_property.phpt ├── decode_max_depth.phpt ├── decode_max_depth_memory_reduction.phpt ├── decode_repeat.phpt ├── decode_result.phpt ├── decode_strict_types.phpt ├── decode_types.phpt ├── depth.phpt ├── dump.inc ├── is_valid.phpt ├── is_valid_args.phpt ├── is_valid_edge_cases.phpt ├── key_count.phpt ├── key_count_args.phpt ├── key_count_exception.phpt ├── key_count_large.phpt ├── key_exists.phpt ├── key_exists_args.phpt ├── key_value_args.phpt ├── key_value_deep_string.phpt ├── key_value_exception.phpt ├── key_value_int.phpt ├── key_value_result.phpt ├── key_value_slash.phpt └── uint64_overflow.phpt /.appveyor.yml: -------------------------------------------------------------------------------- 1 | # Based on php-ast's appveyor config. 2 | # See https://github.com/nikic/php-ast/blob/master/.appveyor.yml 3 | # This tests against PHP 7.0+ 4 | # Author: Tyson Andre 5 | 6 | version: '{branch}.{build}' 7 | 8 | branches: 9 | only: 10 | - master 11 | 12 | clone_folder: c:\projects\simdjson 13 | 14 | install: 15 | ps: | 16 | if (-not (Test-Path c:\build-cache)) { 17 | mkdir c:\build-cache 18 | } 19 | $bname = 'php-sdk-' + $env:BIN_SDK_VER + '.zip' 20 | if (-not (Test-Path c:\build-cache\$bname)) { 21 | Invoke-WebRequest "https://github.com/OSTC/php-sdk-binary-tools/archive/$bname" -OutFile "c:\build-cache\$bname" 22 | } 23 | $dname0 = 'php-sdk-binary-tools-php-sdk-' + $env:BIN_SDK_VER 24 | $dname1 = 'php-sdk-' + $env:BIN_SDK_VER 25 | if (-not (Test-Path c:\build-cache\$dname1)) { 26 | 7z x c:\build-cache\$bname -oc:\build-cache 27 | move c:\build-cache\$dname0 c:\build-cache\$dname1 28 | } 29 | 30 | cache: 31 | c:\build-cache -> .appveyor.yml 32 | 33 | environment: 34 | BIN_SDK_VER: 2.2.0 35 | # Windows builds fail before PHP 7.3. 36 | matrix: 37 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 38 | ARCH: x86 39 | VC: vs16 40 | PHP_VER: 8.2.0RC3 41 | TS: 1 42 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 43 | ARCH: x64 44 | VC: vs16 45 | PHP_VER: 8.2.0RC3 46 | TS: 0 47 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 48 | ARCH: x64 49 | VC: vs16 50 | PHP_VER: 8.1.11 51 | TS: 0 52 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 53 | ARCH: x64 54 | VC: vs16 55 | PHP_VER: 8.0.24 56 | TS: 0 57 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 58 | ARCH: x64 59 | VC: vc15 60 | PHP_VER: 7.3.32 61 | TS: 1 62 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 63 | ARCH: x64 64 | VC: vc15 65 | PHP_VER: 7.4.30 66 | TS: 1 67 | 68 | build_script: 69 | ps: | 70 | # Install the php extension development tools 71 | $ts_part = '' 72 | if ('0' -eq $env:TS) { $ts_part = '-nts' } 73 | $bname = 'php-devel-pack-' + $env:PHP_VER + $ts_part + '-Win32-' + $env:VC.toUpper() + '-' + $env:ARCH + '.zip' 74 | $urls = @( 75 | "https://windows.php.net/downloads/releases/archives/$bname", 76 | "https://windows.php.net/downloads/releases/$bname", 77 | "https://windows.php.net/downloads/qa/$bname", 78 | "https://windows.php.net/downloads/qa/archives/$bname" 79 | ) 80 | foreach ($url in $urls) { 81 | Invoke-WebRequest $url -OutFile "c:\build-cache\$bname" 82 | if (Test-Path c:\build-cache\$bname) { 83 | break; 84 | } 85 | } 86 | $dname0 = 'php-' + $env:PHP_VER + '-devel-' + $env:VC.toUpper() + '-' + $env:ARCH 87 | $dname1 = 'php-' + $env:PHP_VER + $ts_part + '-devel-' + $env:VC.toUpper() + '-' + $env:ARCH 88 | if (-not (Test-Path c:\build-cache\$dname1)) { 89 | 7z x c:\build-cache\$bname -oc:\build-cache 90 | move c:\build-cache\$dname0 c:\build-cache\$dname1 91 | } 92 | $ts_part = '' 93 | if ('0' -eq $env:TS) { $ts_part = '-nts' } 94 | 95 | # Install the php binary 96 | $bname = 'php-' + $env:PHP_VER + $ts_part + '-Win32-' + $env:VC.toUpper() + '-' + $env:ARCH + '.zip' 97 | $urls = @( 98 | "https://windows.php.net/downloads/releases/archives/$bname", 99 | "https://windows.php.net/downloads/releases/$bname", 100 | "https://windows.php.net/downloads/qa/$bname", 101 | "https://windows.php.net/downloads/qa/archives/$bname" 102 | ) 103 | foreach ($url in $urls) { 104 | Invoke-WebRequest $url -OutFile "c:\build-cache\$bname" 105 | if (Test-Path c:\build-cache\$bname) { 106 | break; 107 | } 108 | } 109 | $dname = 'php-' + $env:PHP_VER + $ts_part + '-' + $env:VC.toUpper() + '-' + $env:ARCH 110 | if (-not (Test-Path c:\build-cache\$dname)) { 111 | 7z x c:\build-cache\$bname -oc:\build-cache\$dname 112 | } 113 | cd c:\projects\simdjson 114 | $env:PATH = 'c:\build-cache\' + $dname1 + ';' + $env:PATH 115 | $env:PATH = 'c:\build-cache\' + $dname + ';' + $env:PATH 116 | #echo "@echo off" | Out-File -Encoding "ASCII" task.bat 117 | #echo "" | Out-File -Encoding "ASCII" -Append task.bat 118 | echo "" | Out-File -Encoding "ASCII" task.bat 119 | echo "call phpize 2>&1" | Out-File -Encoding "ASCII" -Append task.bat 120 | 121 | $cmd = 'call configure --enable-simdjson --with-prefix=c:\build-cache\' + $dname + ' 2>&1' 122 | echo $cmd | Out-File -Encoding "ASCII" -Append task.bat 123 | echo "set REPORT_EXIT_STATUS=1" | Out-File -Encoding "ASCII" -Append task.bat 124 | echo "set NO_INTERACTION=1" | Out-File -Encoding "ASCII" -Append task.bat 125 | echo "set TEST_PHP_ARGS=--show-diff" | Out-File -Encoding "ASCII" -Append task.bat 126 | $cmd = 'set TEST_PHP_EXECUTABLE=c:\build-cache\' + $dname + '\php.exe' 127 | echo $cmd | Out-File -Encoding "ASCII" -Append task.bat 128 | echo "nmake /nologo 2>&1" | Out-File -Encoding "ASCII" -Append task.bat 129 | echo "nmake test /nologo 2>&1" | Out-File -Encoding "ASCII" -Append task.bat 130 | echo "exit %errorlevel%" | Out-File -Encoding "ASCII" -Append task.bat 131 | $here = (Get-Item -Path "." -Verbose).FullName 132 | $runner = 'c:\build-cache\php-sdk-' + $env:BIN_SDK_VER + '\phpsdk' + '-' + $env:VC + '-' + $env:ARCH + '.bat' 133 | $task = $here + '\task.bat' 134 | & $runner -t $task 135 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | docker_* 2 | # In dockerignore files, relative paths such as filename are equivalent to /filename in the project root directory 3 | **/.deps 4 | **/*.swp 5 | **/*.swo 6 | **/.git 7 | **/acinclude.m4 8 | **/aclocal.m4 9 | **/autom4te.cache/ 10 | **/benchmark/ 11 | **/build/ 12 | **/CMakeFiles/ 13 | **/config.h 14 | **/config.log 15 | **/config.nice 16 | **/config.status 17 | **/config.guess 18 | **/config.h.in 19 | **/config.sub 20 | **/configure 21 | **/configure.in 22 | **/install-sh 23 | **/jsonexamples/ 24 | **/ltmain.sh 25 | **/missing 26 | **/mkinstalldirs 27 | **/run-tests.php 28 | **/scripts 29 | **/Makefile 30 | **/Makefile.* 31 | **/!Makefile.frag 32 | **/libtool 33 | *~ 34 | **/modules/ 35 | **/.libs/ 36 | **/*.la 37 | **/*.lo 38 | **/*.dep 39 | **/*.tgz 40 | **/php_test_results_*.txt 41 | *~ 42 | **/configure.ac 43 | /cmake-* 44 | /run-php 45 | **/benchmark/vendor 46 | **/composer.lock 47 | **/.idea 48 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org/ 2 | 3 | root = true 4 | 5 | [*] 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | end_of_line = lf 9 | charset = utf-8 10 | tab_width = 4 11 | indent_size = 4 12 | indent_style = space 13 | -------------------------------------------------------------------------------- /.github/workflows/integration.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | PHP82-alpine: 6 | name: PHP 8.2 Alpine 3.16 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: "Checkout" 10 | uses: actions/checkout@v2 11 | 12 | - name: "Build extension" 13 | run: "docker build -t simdjsontest -f docker_php8.2-alpine ." 14 | 15 | - name: "Show" 16 | run: "docker run --rm --env SIMDJSON_HIGH_MEMORY_TESTS=1 simdjsontest php --ri simdjson" 17 | 18 | PHP81-alpine: 19 | name: PHP 8.1 Alpine 3.15 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: "Checkout" 23 | uses: actions/checkout@v2 24 | 25 | - name: "Build extension" 26 | run: "docker build -t simdjsontest -f docker_php8.1-alpine ." 27 | 28 | - name: "Show" 29 | run: "docker run --rm --env SIMDJSON_HIGH_MEMORY_TESTS=1 simdjsontest php --ri simdjson" 30 | 31 | PHP80-alpine: 32 | name: PHP 8.0 Alpine 3.12 33 | runs-on: ubuntu-latest 34 | steps: 35 | - name: "Checkout" 36 | uses: actions/checkout@v2 37 | 38 | - name: "Build extension" 39 | run: "docker build -t simdjsontest -f docker_php8.0-alpine ." 40 | 41 | - name: "Show" 42 | run: "docker run --rm --env SIMDJSON_HIGH_MEMORY_TESTS=1 simdjsontest php --ri simdjson" 43 | 44 | PHP74-alpine: 45 | name: PHP 7.4 Alpine 3.12 46 | runs-on: ubuntu-latest 47 | steps: 48 | - name: "Checkout" 49 | uses: actions/checkout@v2 50 | 51 | - name: "Build extension" 52 | run: "docker build -t simdjsontest -f docker_php7.4-alpine ." 53 | 54 | - name: "Show" 55 | run: "docker run --rm --env SIMDJSON_HIGH_MEMORY_TESTS=1 simdjsontest php --ri simdjson" 56 | 57 | PHP73-alpine: 58 | name: PHP 7.3 Alpine 3.12 59 | runs-on: ubuntu-latest 60 | steps: 61 | - name: "Checkout" 62 | uses: actions/checkout@v2 63 | 64 | - name: "Build extension" 65 | run: "docker build -t simdjsontest -f docker_php7.3-alpine ." 66 | 67 | - name: "Show" 68 | run: "docker run --rm --env SIMDJSON_HIGH_MEMORY_TESTS=1 simdjsontest php --ri simdjson" 69 | 70 | PHP72-alpine: 71 | name: PHP 7.2 Alpine 3.12 72 | runs-on: ubuntu-latest 73 | steps: 74 | - name: "Checkout" 75 | uses: actions/checkout@v2 76 | 77 | - name: "Build extension" 78 | run: "docker build -t simdjsontest -f docker_php7.2-alpine ." 79 | 80 | - name: "Show" 81 | run: "docker run --rm --env SIMDJSON_HIGH_MEMORY_TESTS=1 simdjsontest php --ri simdjson" 82 | 83 | PHP71-alpine: 84 | name: PHP 7.1 Alpine 3.10 85 | runs-on: ubuntu-latest 86 | steps: 87 | - name: "Checkout" 88 | uses: actions/checkout@v2 89 | 90 | - name: "Build extension" 91 | run: "docker build -t simdjsontest -f docker_php7.1-alpine ." 92 | 93 | - name: "Show" 94 | run: "docker run --rm --env SIMDJSON_HIGH_MEMORY_TESTS=1 simdjsontest php --ri simdjson" 95 | 96 | Ubuntu: 97 | strategy: 98 | fail-fast: false 99 | matrix: 100 | php-version: 101 | - "7.0" 102 | - "7.1" 103 | - "7.2" 104 | - "7.3" 105 | - "7.4" 106 | - "8.0" 107 | - "8.1" 108 | os: [ubuntu-latest] 109 | experimental: [false] 110 | runs-on: ${{ matrix.os }} 111 | name: PHP ${{ matrix.php-version }} Test on ${{ matrix.os }} 112 | continue-on-error: ${{ matrix.experimental }} 113 | steps: 114 | - name: "Checkout" 115 | uses: actions/checkout@v2 116 | 117 | - name: "Install PHP" 118 | uses: shivammathur/setup-php@v2 119 | with: 120 | php-version: "${{ matrix.php-version }}" 121 | extensions: json 122 | # for correct php-config extension dir, see https://github.com/shivammathur/setup-php/issues/147 123 | tools: pecl, phpize, php-config 124 | - name: "Build extension" 125 | run: | 126 | export NO_INTERACTION=true 127 | export REPORT_EXIT_STATUS=1 128 | export SIMDJSON_HIGH_MEMORY_TESTS=1 129 | php-config --extension-dir 130 | phpize 131 | ./configure 132 | make 133 | sudo make install 134 | make test TESTS="--show-diff" || exit 1 135 | 136 | - name: "Show" 137 | run: "php -dextension=simdjson.so --ri simdjson" 138 | 139 | - name: "Error log" 140 | if: ${{ failure() }} 141 | run: "ls -1t tests/*.log | xargs -d'\n' cat" 142 | 143 | - name: "Error diff" 144 | if: ${{ failure() }} 145 | run: | 146 | for FILE in $(find tests -name '*.diff'); do 147 | echo $FILE 148 | cat $FILE 149 | echo 150 | done 151 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.tgz 4 | .deps 5 | acinclude.m4 6 | aclocal.m4 7 | autom4te.cache/ 8 | build/ 9 | config.h 10 | config.log 11 | config.nice 12 | config.status 13 | config.guess 14 | config.h.in 15 | config.sub 16 | configure 17 | configure.in 18 | install-sh 19 | ltmain.sh 20 | missing 21 | mkinstalldirs 22 | run-tests.php 23 | Makefile 24 | Makefile.* 25 | !Makefile.frag 26 | libtool 27 | *~ 28 | modules/ 29 | .libs/ 30 | *.la 31 | *.lo 32 | *.dep 33 | php_test_results_*.txt 34 | tests/* 35 | !tests/**/*.phpt 36 | !tests/_files/ 37 | *~ 38 | configure.ac 39 | /cmake-* 40 | /run-php 41 | benchmark/vendor 42 | composer.lock 43 | .idea 44 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | project(simdjson) 3 | 4 | add_compile_definitions(HAVE_SIMDJSON) 5 | 6 | set(SOURCE_FILES 7 | php_simdjson.h 8 | simdjson.cpp 9 | src/bindings.h 10 | src/bindings.cpp 11 | src/simdjson.h 12 | src/simdjson.cpp 13 | ) 14 | 15 | execute_process ( 16 | COMMAND php-config --include-dir 17 | OUTPUT_VARIABLE PHP_SOURCE 18 | ) 19 | string(REGEX REPLACE "\n$" "" PHP_SOURCE "${PHP_SOURCE}") 20 | 21 | message("Using source directory: ${PHP_SOURCE}") 22 | 23 | include_directories( 24 | "${PHP_SOURCE}" 25 | "${PHP_SOURCE}/main" 26 | "${PHP_SOURCE}/Zend" 27 | "${PHP_SOURCE}/TSRM" 28 | "${PROJECT_SOURCE_DIR}" 29 | ) 30 | 31 | add_custom_target(configure 32 | COMMAND phpize && ./configure 33 | DEPENDS ${SOURCE_FILES} 34 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) 35 | 36 | add_library(___ EXCLUDE_FROM_ALL ${SOURCE_FILES}) 37 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | JinXi Wang(1054636713@qq.com) 2 | QQ: 1054636713 3 | -------------------------------------------------------------------------------- /benchmark/README.md: -------------------------------------------------------------------------------- 1 | # Benchmark 2 | 3 | ## Build project 4 | 5 | Build the project from the project root folder: 6 | 7 | ``` 8 | phpize 9 | ./configure 10 | make 11 | make test 12 | ``` 13 | 14 | ## Install PHP Composer dependencies 15 | 16 | [Install Composer](https://getcomposer.org/download/) if not already done and execute it in the benchmark folder: 17 | 18 | ``` 19 | composer install 20 | ``` 21 | 22 | ## Run PHPBench benchmark 23 | 24 | Execute from project root folder: 25 | 26 | ``` 27 | php benchmark/vendor/bin/phpbench run --report=table --group decode 28 | ``` 29 | 30 | The output should look like this (Example output is using an optimized php 7.4 NTS build with the simdjson Intel/AMD AVX2 implementation): 31 | 32 | ``` 33 | \SimdjsonBench\DecodeBench 34 | 35 | jsonDecodeAssoc.........................R1 I1 [μ Mo]/r: 0.00388 0.00381 (ms) [μSD μRSD]/r: 0.000ms 2.53% 36 | jsonDecode..............................R1 I4 [μ Mo]/r: 0.00412 0.00419 (ms) [μSD μRSD]/r: 0.000ms 2.38% 37 | simdjsonDecodeAssoc.....................R1 I4 [μ Mo]/r: 0.00160 0.00160 (ms) [μSD μRSD]/r: 0.000ms 0.00% 38 | simdjsonDecode..........................R5 I4 [μ Mo]/r: 0.00200 0.00200 (ms) [μSD μRSD]/r: 0.000ms 0.00% 39 | 40 | 4 subjects, 20 iterations, 20 revs, 0 rejects, 0 failures, 0 warnings 41 | (best [mean mode] worst) = 1.600 [2.900 2.900] 1.600 (μs) 42 | ⅀T: 58.000μs μSD/r 0.049μs μRSD/r: 1.226% 43 | suite: 1348b91b9c795a97081586821cb7ad40fcf92c64, date: 2022-08-17, stime: 00:01:20 44 | +-------------+---------------------+--------+----------+-----------+-----------+-------+ 45 | | benchmark | subject | groups | mem_peak | mean | best | diff | 46 | +-------------+---------------------+--------+----------+-----------+-----------+-------+ 47 | | DecodeBench | simdjsonDecodeAssoc | decode | 597,696b | 0.00160ms | 0.00160ms | 1.00x | 48 | | DecodeBench | simdjsonDecode | decode | 597,664b | 0.00200ms | 0.00200ms | 1.25x | 49 | | DecodeBench | jsonDecodeAssoc | decode | 597,664b | 0.00388ms | 0.00380ms | 2.43x | 50 | | DecodeBench | jsonDecode | decode | 597,664b | 0.00412ms | 0.00400ms | 2.58x | 51 | +-------------+---------------------+--------+----------+-----------+-----------+-------+ 52 | ``` 53 | 54 | ``` 55 | php benchmark/vendor/bin/phpbench run --report=table --group key_value 56 | ``` 57 | 58 | The output should look like this: 59 | 60 | ``` 61 | \SimdjsonBench\KeyValueBench 62 | 63 | jsonDecode..............................R1 I0 [μ Mo]/r: 0.00400 0.00400 (ms) [μSD μRSD]/r: 0.000ms 0.00% 64 | simdjsonDeepString......................R5 I4 [μ Mo]/r: 0.00080 0.00080 (ms) [μSD μRSD]/r: 0.000ms 0.00% 65 | simdjsonDeepStringAssoc.................R2 I1 [μ Mo]/r: 0.00080 0.00080 (ms) [μSD μRSD]/r: 0.000ms 0.00% 66 | simdjsonInt.............................R2 I2 [μ Mo]/r: 0.00060 0.00060 (ms) [μSD μRSD]/r: 0.000ms 0.00% 67 | simdjsonIntAssoc........................R5 I4 [μ Mo]/r: 0.00080 0.00080 (ms) [μSD μRSD]/r: 0.000ms 0.00% 68 | simdjsonArray...........................R1 I3 [μ Mo]/r: 0.00100 0.00100 (ms) [μSD μRSD]/r: 0.000ms 0.00% 69 | simdjsonObject..........................R5 I4 [μ Mo]/r: 0.00100 0.00100 (ms) [μSD μRSD]/r: 0.000ms 0.00% 70 | 71 | 7 subjects, 35 iterations, 35 revs, 0 rejects, 0 failures, 0 warnings 72 | (best [mean mode] worst) = 0.600 [1.286 1.286] 0.600 (μs) 73 | ⅀T: 45.000μs μSD/r 0.000μs μRSD/r: 0.000% 74 | suite: 1348b91bf021f090195aa64f9e32bb9787e2aba7, date: 2022-08-17, stime: 00:00:39 75 | +---------------+-------------------------+-----------+----------+-----------+-----------+-------+ 76 | | benchmark | subject | groups | mem_peak | mean | best | diff | 77 | +---------------+-------------------------+-----------+----------+-----------+-----------+-------+ 78 | | KeyValueBench | simdjsonInt | key_value | 597,680b | 0.00060ms | 0.00060ms | 1.00x | 79 | | KeyValueBench | simdjsonDeepString | key_value | 597,712b | 0.00080ms | 0.00080ms | 1.33x | 80 | | KeyValueBench | simdjsonDeepStringAssoc | key_value | 597,712b | 0.00080ms | 0.00080ms | 1.33x | 81 | | KeyValueBench | simdjsonIntAssoc | key_value | 597,712b | 0.00080ms | 0.00080ms | 1.33x | 82 | | KeyValueBench | simdjsonArray | key_value | 597,680b | 0.00100ms | 0.00100ms | 1.67x | 83 | | KeyValueBench | simdjsonObject | key_value | 597,680b | 0.00100ms | 0.00100ms | 1.67x | 84 | | KeyValueBench | jsonDecode | key_value | 597,680b | 0.00400ms | 0.00400ms | 6.67x | 85 | +---------------+-------------------------+-----------+----------+-----------+-----------+-------+ 86 | ``` 87 | 88 | ``` 89 | php benchmark/vendor/bin/phpbench run --report=table --group multiple 90 | ``` 91 | 92 | The output should look like this: 93 | 94 | ``` 95 | \SimdjsonBench\MultipleAccessBench 96 | 97 | simdjsonMultipleAccessSameDocument......R5 I4 [μ Mo]/r: 0.00424 0.00420 (ms) [μSD μRSD]/r: 0.000ms 1.89% 98 | simdjsonMultipleAccessDifferentDocument.R2 I4 [μ Mo]/r: 0.00472 0.00479 (ms) [μSD μRSD]/r: 0.000ms 2.08% 99 | 100 | 2 subjects, 10 iterations, 10 revs, 0 rejects, 0 failures, 0 warnings 101 | (best [mean mode] worst) = 4.200 [4.480 4.497] 4.400 (μs) 102 | ⅀T: 44.800μs μSD/r 0.089μs μRSD/r: 1.981% 103 | suite: 1348b906f3a3db7db83e25ab05aeb9a8b3091a84, date: 2022-08-16, stime: 23:59:25 104 | +---------------------+-----------------------------------------+----------+----------+-----------+-----------+-------+ 105 | | benchmark | subject | groups | mem_peak | mean | best | diff | 106 | +---------------------+-----------------------------------------+----------+----------+-----------+-----------+-------+ 107 | | MultipleAccessBench | simdjsonMultipleAccessSameDocument | multiple | 597,784b | 0.00424ms | 0.00420ms | 1.00x | 108 | | MultipleAccessBench | simdjsonMultipleAccessDifferentDocument | multiple | 597,784b | 0.00472ms | 0.00460ms | 1.11x | 109 | +---------------------+-----------------------------------------+----------+----------+-----------+-----------+-------+ 110 | ``` 111 | 112 | ## Run benchmark 113 | 114 | You may also run a simpler standalone benchmark script on the JSON files in [`jsonexamples`](../jsonexamples) by running the commands: 115 | 116 | ``` 117 | php -d extension=modules/simdjson.so benchmark/benchmark.php 118 | ``` 119 | 120 | For decoding functions, the benchmark includes both the time to decode the data and the time to garbage collect/free the decoded data. 121 | 122 | The output should look like this 123 | 124 | ``` 125 | filename|json_decode|simdjson_decode|simdjson_is_valid|relative_decode|relative_is_valid 126 | ---|:--:|---:|---:|---:|--: 127 | apache_builds.json|529445|252983|57314|0.48x|0.11x 128 | canada.json|37480906|9114440|3594688|0.24x|0.10x 129 | citm_catalog.json|6211875|3034887|992156|0.49x|0.16x 130 | github_events.json|274541|101767|30350|0.37x|0.11x 131 | gsoc-2018.json|13174491|4000738|1771096|0.30x|0.13x 132 | instruments.json|1051116|396716|133227|0.38x|0.13x 133 | marine_ik.json|25511155|13070490|4951457|0.51x|0.19x 134 | mesh.json|6063492|2246089|1191093|0.37x|0.20x 135 | mesh.pretty.json|10617360|2659494|1634062|0.25x|0.15x 136 | numbers.json|1017109|328689|213022|0.32x|0.21x 137 | random.json|3158095|1526622|402568|0.48x|0.13x 138 | stringifiedphp.json|591071|99104|86034|0.17x|0.15x 139 | twitter.json|2589313|997667|354375|0.39x|0.14x 140 | twitterescaped.json|3089506|1156811|553984|0.37x|0.18x 141 | update-center.json|3084217|1227891|336303|0.40x|0.11x 142 | ``` 143 | 144 | - `canada.json` is an example of a string with a lot of floats (polygon for a map of canada). 145 | Same for the `mesh*.json` files and `numbers.json` file 146 | - `stringifiedphp.json` is an example of a single long JSON encoded string (representation of php file with newlines and quotes). 147 | - `twitter.json` is an example of decoding data with a mix of types with a lot of non-ascii codepoints. 148 | `twitterescaped.json` is the same data with `"\uXXXX"` escaping and no whitespace. 149 | - `random.json` is a large object with a lot of short keys, small objects/arrays, and short string/integer values, with some non-ASCII values. 150 | `apache_builds.json` contains a lot of whitespace and relatively small objects, string keys, and mostly string values. 151 | -------------------------------------------------------------------------------- /benchmark/benchmark.php: -------------------------------------------------------------------------------- 1 | json = <<json, true); 75 | 76 | if ('World3' !== $data['result'][0]['Hello3']) { 77 | throw new \RuntimeException('error'); 78 | } 79 | } 80 | 81 | /** 82 | * @Subject() 83 | */ 84 | public function jsonDecode(): void 85 | { 86 | $data = json_decode($this->json, false); 87 | 88 | if ('World3' !== $data->result[0]->Hello3) { 89 | throw new \RuntimeException('error'); 90 | } 91 | } 92 | 93 | /** 94 | * @Subject() 95 | */ 96 | public function simdjsonDecodeAssoc() 97 | { 98 | $data = \simdjson_decode($this->json, true); 99 | 100 | if ('World3' !== $data['result'][0]['Hello3']) { 101 | throw new \RuntimeException('error'); 102 | } 103 | } 104 | 105 | /** 106 | * @Subject() 107 | */ 108 | public function simdjsonDecode() 109 | { 110 | $data = \simdjson_decode($this->json, false); 111 | 112 | if ('World3' !== $data->result[0]->Hello3) { 113 | throw new \RuntimeException('error'); 114 | } 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /benchmark/phpbench/KeyValueBench.php: -------------------------------------------------------------------------------- 1 | json = <<json, true); 75 | 76 | if ('World3' !== $data['result'][0]['Hello3']) { 77 | throw new \RuntimeException('error'); 78 | } 79 | } 80 | 81 | /** 82 | * @Subject() 83 | */ 84 | public function simdjsonDeepString() 85 | { 86 | $value = \simdjson_key_value($this->json, "result/0/Hello3", false); 87 | 88 | if ('World3' !== $value) { 89 | throw new \RuntimeException('error'); 90 | } 91 | } 92 | 93 | /** 94 | * @Subject() 95 | */ 96 | public function simdjsonDeepStringAssoc() 97 | { 98 | $value = \simdjson_key_value($this->json, "result/0/Hello3", true); 99 | 100 | if ('World3' !== $value) { 101 | throw new \RuntimeException('error'); 102 | } 103 | } 104 | 105 | /** 106 | * @Subject() 107 | */ 108 | public function simdjsonInt() 109 | { 110 | $value = \simdjson_key_value($this->json, "code", false); 111 | 112 | if (201 !== $value) { 113 | throw new \RuntimeException('error'); 114 | } 115 | } 116 | 117 | /** 118 | * @Subject() 119 | */ 120 | public function simdjsonIntAssoc() 121 | { 122 | $value = \simdjson_key_value($this->json, "code", true); 123 | 124 | if (201 !== $value) { 125 | throw new \RuntimeException('error'); 126 | } 127 | } 128 | 129 | /** 130 | * @Subject() 131 | */ 132 | public function simdjsonArray() 133 | { 134 | $value = \simdjson_key_value($this->json, "result", true); 135 | 136 | if ('World3' !== $value[0]['Hello3']) { 137 | throw new \RuntimeException('error'); 138 | } 139 | } 140 | 141 | /** 142 | * @Subject() 143 | */ 144 | public function simdjsonObject() 145 | { 146 | $value = \simdjson_key_value($this->json, "result", false); 147 | 148 | if ('World3' !== $value[0]->Hello3) { 149 | throw new \RuntimeException('error'); 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /benchmark/phpbench/MultipleAccessBench.php: -------------------------------------------------------------------------------- 1 | json = <<jsonOther = <<json, "result/0/Hello3", true); 99 | $value2 = \simdjson_key_value($this->json, "code", true); 100 | $value3 = \simdjson_key_value($this->json, "hasMore", true); 101 | $value4 = \simdjson_key_value($this->json, "count", true); 102 | $valueOther = \simdjson_key_value($this->jsonOther, "Image/Width", true); 103 | $valueOther2 = \simdjson_key_value($this->jsonOther, "Cached", true); 104 | $valueOther3 = \simdjson_key_value($this->jsonOther, "HasMore", true); 105 | $valueOther4 = \simdjson_key_value($this->jsonOther, "Count", true); 106 | 107 | if ('World3' !== $value) { 108 | throw new \RuntimeException('error'); 109 | } 110 | if (201 !== $value2) { 111 | throw new \RuntimeException('error'); 112 | } 113 | if (false !== $value3) { 114 | throw new \RuntimeException('error'); 115 | } 116 | if (2 !== $value4) { 117 | throw new \RuntimeException('error'); 118 | } 119 | 120 | if (800 !== $valueOther) { 121 | throw new \RuntimeException('error'); 122 | } 123 | if (false !== $valueOther2) { 124 | throw new \RuntimeException('error'); 125 | } 126 | if (true !== $valueOther3) { 127 | throw new \RuntimeException('error'); 128 | } 129 | if (4 !== $valueOther4) { 130 | throw new \RuntimeException('error'); 131 | } 132 | } 133 | 134 | /** 135 | * @Subject() 136 | */ 137 | public function simdjsonMultipleAccessDifferentDocument() 138 | { 139 | $value = \simdjson_key_value($this->json, "result/0/Hello3", true); 140 | $valueOther = \simdjson_key_value($this->jsonOther, "Image/Width", true); 141 | $value2 = \simdjson_key_value($this->json, "code", true); 142 | $valueOther2 = \simdjson_key_value($this->jsonOther, "Cached", true); 143 | $value3 = \simdjson_key_value($this->json, "hasMore", true); 144 | $valueOther3 = \simdjson_key_value($this->jsonOther, "HasMore", true); 145 | $value4 = \simdjson_key_value($this->json, "count", true); 146 | $valueOther4 = \simdjson_key_value($this->jsonOther, "Count", true); 147 | 148 | if ('World3' !== $value) { 149 | throw new \RuntimeException('error'); 150 | } 151 | if (201 !== $value2) { 152 | throw new \RuntimeException('error'); 153 | } 154 | if (false !== $value3) { 155 | throw new \RuntimeException('error'); 156 | } 157 | if (2 !== $value4) { 158 | throw new \RuntimeException('error'); 159 | } 160 | 161 | if (800 !== $valueOther) { 162 | throw new \RuntimeException('error'); 163 | } 164 | if (false !== $valueOther2) { 165 | throw new \RuntimeException('error'); 166 | } 167 | if (true !== $valueOther3) { 168 | throw new \RuntimeException('error'); 169 | } 170 | if (4 !== $valueOther4) { 171 | throw new \RuntimeException('error'); 172 | } 173 | } 174 | 175 | 176 | } 177 | -------------------------------------------------------------------------------- /benchmark/phpbench/SingleCharStringsBench.php: -------------------------------------------------------------------------------- 1 | chr(48 + $i % 10), 'y' => chr(48 + $i % 8), 's' => '']; 42 | } 43 | $this->json = \json_encode($raw); 44 | } 45 | 46 | /** 47 | * @Subject() 48 | */ 49 | public function jsonDecodeAssoc(): void 50 | { 51 | $data = \json_decode($this->json, true); 52 | 53 | if ('0' !== $data[0]['x']) { 54 | throw new \RuntimeException('error'); 55 | } 56 | } 57 | 58 | /** 59 | * @Subject() 60 | */ 61 | public function jsonDecode(): void 62 | { 63 | $data = \json_decode($this->json, false); 64 | 65 | if ('0' !== $data[0]->x) { 66 | throw new \RuntimeException('error'); 67 | } 68 | } 69 | 70 | /** 71 | * @Subject() 72 | */ 73 | public function simdjsonDecodeAssoc() 74 | { 75 | $data = \simdjson_decode($this->json, true); 76 | 77 | if ('0' !== $data[0]['x']) { 78 | throw new \RuntimeException('error'); 79 | } 80 | } 81 | 82 | /** 83 | * @Subject() 84 | */ 85 | public function simdjsonDecode() 86 | { 87 | $data = \simdjson_decode($this->json, false); 88 | 89 | if ('0' !== $data[0]->x) { 90 | throw new \RuntimeException('error'); 91 | } 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl config.m4 for extension simdjson 2 | 3 | PHP_ARG_ENABLE(simdjson, whether to enable simdjson, [ --enable-simdjson Enable simdjson]) 4 | 5 | if test "$PHP_SIMDJSON" != "no"; then 6 | 7 | PHP_REQUIRE_CXX() 8 | 9 | AC_MSG_CHECKING([PHP version]) 10 | 11 | if test -z "$PHP_CONFIG"; then 12 | AC_MSG_ERROR([php-config not found]) 13 | fi 14 | php_version=`$PHP_CONFIG --vernum` 15 | 16 | if test -z "$php_version"; then 17 | AC_MSG_ERROR([failed to detect PHP version, please report]) 18 | fi 19 | 20 | if test "$php_version" -lt "70000"; then 21 | AC_MSG_ERROR([You need at least PHP 7.0.0 to be able to use this version of simdjson. PHP $php_version found]) 22 | else 23 | AC_MSG_RESULT([$php_version, ok]) 24 | fi 25 | 26 | dnl Mark symbols hidden by default if the compiler (for example, gcc >= 4) 27 | dnl supports it. This can help reduce the binary size and startup time. 28 | AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], 29 | [CXXFLAGS="$CXXFLAGS -fvisibility=hidden"]) 30 | 31 | AC_DEFINE(HAVE_SIMDJSON, 1, [whether simdjson is enabled]) 32 | dnl Disable exceptions because PHP is written in C and loads this C++ module, handle errors manually. 33 | dnl Disable development checks of C simdjson library in php debug builds (can manually override) 34 | PHP_NEW_EXTENSION(simdjson, [ 35 | php_simdjson.cpp \ 36 | src/simdjson_bindings.cpp \ 37 | src/simdjson.cpp], 38 | $ext_shared,, "-std=c++17 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DSIMDJSON_EXCEPTIONS=0 -DSIMDJSON_DEVELOPMENT_CHECKS=0", cxx) 39 | 40 | PHP_INSTALL_HEADERS([ext/simdjson], [php_simdjson.h src/simdjson_bindings_defs.h]) 41 | PHP_ADD_MAKEFILE_FRAGMENT 42 | PHP_ADD_BUILD_DIR(src, 1) 43 | fi 44 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | ARG_ENABLE("simdjson", "whether to enable simdjson support", "no"); 2 | 3 | if (PHP_SIMDJSON == "yes") { 4 | AC_DEFINE('HAVE_SIMDJSON', 1, 'Have simdjson support', false); 5 | 6 | // NOTE: The linker requires that the files have different basenames, so simdjson.cpp was 7 | // renamed to php_simdjson.cpp 8 | EXTENSION('simdjson', 9 | 'php_simdjson.cpp', 10 | 'yes', 11 | '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /std:c++latest'); 12 | ADD_SOURCES(configure_module_dirname + '/src', 'simdjson.cpp simdjson_bindings.cpp', 'simdjson'); 13 | ADD_FLAG('CFLAGS_SIMDJSON', '/I' + configure_module_dirname); 14 | PHP_INSTALL_HEADERS('ext/simdjson', 'php_simdjson.h src/simdjson_bindings_defs.h'); 15 | } 16 | // vim:ft=javascript 17 | -------------------------------------------------------------------------------- /docker_php7.1-alpine: -------------------------------------------------------------------------------- 1 | FROM php:7.1.33-alpine3.10 2 | 3 | # json_encode is used in some phpt test cases 4 | RUN docker-php-ext-install -j$(nproc) json 5 | 6 | COPY . /tmp/simdjson 7 | 8 | # persistent / runtime deps 9 | ENV PHPIZE_DEPS \ 10 | autoconf \ 11 | g++ \ 12 | gcc \ 13 | make \ 14 | pkgconf \ 15 | git \ 16 | re2c 17 | 18 | ENV REPORT_EXIT_STATUS=1 19 | 20 | RUN set -xe \ 21 | && apk add --no-cache --virtual .build-deps \ 22 | $PHPIZE_DEPS \ 23 | && cd /tmp/simdjson \ 24 | && phpize \ 25 | && ./configure \ 26 | && make -j$(nproc) \ 27 | && make install \ 28 | && make test \ 29 | && rm -rf /tmp/simdjson \ 30 | && echo "extension=simdjson.so" > /usr/local/etc/php/conf.d/simdjson.ini 31 | -------------------------------------------------------------------------------- /docker_php7.2-alpine: -------------------------------------------------------------------------------- 1 | FROM php:7.2-cli-alpine3.12 2 | 3 | # json_encode is used in some phpt test cases 4 | RUN docker-php-ext-install -j$(nproc) json 5 | 6 | COPY . /tmp/simdjson 7 | 8 | # persistent / runtime deps 9 | ENV PHPIZE_DEPS \ 10 | autoconf \ 11 | g++ \ 12 | gcc \ 13 | make \ 14 | pkgconf \ 15 | git \ 16 | re2c 17 | 18 | ENV REPORT_EXIT_STATUS=1 19 | 20 | RUN set -xe \ 21 | && apk add --no-cache --virtual .build-deps \ 22 | $PHPIZE_DEPS \ 23 | && cd /tmp/simdjson \ 24 | && phpize \ 25 | && ./configure \ 26 | && make \ 27 | && make install \ 28 | && make test \ 29 | && rm -rf /tmp/simdjson \ 30 | && echo "extension=simdjson.so" > /usr/local/etc/php/conf.d/simdjson.ini 31 | -------------------------------------------------------------------------------- /docker_php7.3-alpine: -------------------------------------------------------------------------------- 1 | # DO NOT MODIFY THIS AUTOGENERATED FILE 2 | # Change it in m4 folder 3 | FROM php:7.3-cli-alpine3.12 4 | 5 | # json_encode is used in some phpt test cases 6 | RUN docker-php-ext-install -j$(nproc) json 7 | 8 | COPY . /tmp/simdjson 9 | 10 | # persistent / runtime deps 11 | ENV PHPIZE_DEPS \ 12 | autoconf \ 13 | g++ \ 14 | gcc \ 15 | make \ 16 | pkgconf \ 17 | git \ 18 | re2c 19 | 20 | ENV REPORT_EXIT_STATUS=1 21 | 22 | RUN set -xe \ 23 | && apk add --no-cache --virtual .build-deps \ 24 | $PHPIZE_DEPS \ 25 | && cd /tmp/simdjson \ 26 | && phpize \ 27 | && ./configure \ 28 | && make -j$(nproc) \ 29 | && make install \ 30 | && make test \ 31 | && rm -rf /tmp/simdjson \ 32 | && echo "extension=simdjson.so" > /usr/local/etc/php/conf.d/simdjson.ini 33 | -------------------------------------------------------------------------------- /docker_php7.4-alpine: -------------------------------------------------------------------------------- 1 | # DO NOT MODIFY THIS AUTOGENERATED FILE 2 | # Change it in m4 folder 3 | FROM php:7.4-cli-alpine3.12 4 | 5 | # json_encode is used in some phpt test cases 6 | RUN docker-php-ext-install -j$(nproc) json 7 | 8 | COPY . /tmp/simdjson 9 | 10 | # persistent / runtime deps 11 | ENV PHPIZE_DEPS \ 12 | autoconf \ 13 | g++ \ 14 | gcc \ 15 | make \ 16 | pkgconf \ 17 | git \ 18 | re2c 19 | 20 | ENV REPORT_EXIT_STATUS=1 21 | 22 | RUN set -xe \ 23 | && apk add --no-cache --virtual .build-deps \ 24 | $PHPIZE_DEPS \ 25 | && cd /tmp/simdjson \ 26 | && phpize \ 27 | && ./configure \ 28 | && make -j$(nproc) \ 29 | && make install \ 30 | && make test \ 31 | && rm -rf /tmp/simdjson \ 32 | && echo "extension=simdjson.so" > /usr/local/etc/php/conf.d/simdjson.ini 33 | -------------------------------------------------------------------------------- /docker_php8.0-alpine: -------------------------------------------------------------------------------- 1 | # DO NOT MODIFY THIS AUTOGENERATED FILE 2 | # Change it in m4 folder 3 | FROM php:8.0-cli-alpine3.12 4 | 5 | COPY . /tmp/simdjson 6 | 7 | # persistent / runtime deps 8 | ENV PHPIZE_DEPS \ 9 | autoconf \ 10 | g++ \ 11 | gcc \ 12 | make \ 13 | pkgconf \ 14 | git \ 15 | re2c 16 | 17 | ENV REPORT_EXIT_STATUS=1 18 | 19 | RUN set -xe \ 20 | && apk add --no-cache --virtual .build-deps \ 21 | $PHPIZE_DEPS \ 22 | && cd /tmp/simdjson \ 23 | && phpize \ 24 | && ./configure \ 25 | && make -j$(nproc) \ 26 | && make install \ 27 | && make test \ 28 | && rm -rf /tmp/simdjson \ 29 | && echo "extension=simdjson.so" > /usr/local/etc/php/conf.d/simdjson.ini 30 | -------------------------------------------------------------------------------- /docker_php8.1-alpine: -------------------------------------------------------------------------------- 1 | # DO NOT MODIFY THIS AUTOGENERATED FILE 2 | # Change it in m4 folder 3 | FROM php:8.1-cli-alpine3.15 4 | 5 | COPY . /tmp/simdjson 6 | 7 | # persistent / runtime deps 8 | ENV PHPIZE_DEPS \ 9 | autoconf \ 10 | g++ \ 11 | gcc \ 12 | make \ 13 | pkgconf \ 14 | git \ 15 | re2c 16 | 17 | ENV REPORT_EXIT_STATUS=1 18 | 19 | RUN set -xe \ 20 | && apk add --no-cache --virtual .build-deps \ 21 | $PHPIZE_DEPS \ 22 | && cd /tmp/simdjson \ 23 | && phpize \ 24 | && ./configure \ 25 | && make -j$(nproc) \ 26 | && make install \ 27 | && make test \ 28 | && rm -rf /tmp/simdjson \ 29 | && echo "extension=simdjson.so" > /usr/local/etc/php/conf.d/simdjson.ini 30 | -------------------------------------------------------------------------------- /docker_php8.2-alpine: -------------------------------------------------------------------------------- 1 | FROM php:8.2.0RC2-cli-alpine3.16 2 | 3 | COPY . /tmp/simdjson 4 | 5 | # persistent / runtime deps 6 | ENV PHPIZE_DEPS \ 7 | autoconf \ 8 | g++ \ 9 | gcc \ 10 | make \ 11 | pkgconf \ 12 | git \ 13 | re2c 14 | 15 | ENV REPORT_EXIT_STATUS=1 16 | 17 | RUN set -xe \ 18 | && apk add --no-cache --virtual .build-deps \ 19 | $PHPIZE_DEPS \ 20 | && cd /tmp/simdjson \ 21 | && phpize \ 22 | && ./configure \ 23 | && make -j$(nproc) \ 24 | && make install \ 25 | && make test \ 26 | && rm -rf /tmp/simdjson \ 27 | && echo "extension=simdjson.so" > /usr/local/etc/php/conf.d/simdjson.ini 28 | -------------------------------------------------------------------------------- /jsonexamples/small/adversarial.json: -------------------------------------------------------------------------------- 1 | { 2 | "\"Name rue": [ 3 | [ 116, 4 | "\"", 5 | 234, 6 | "true", 7 | false ] 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /jsonexamples/small/demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Image": { 3 | "Width": 800, 4 | "Height": 600, 5 | "Title": "View from 15th Floor", 6 | "Thumbnail": { 7 | "Url": "http://www.example.com/image/481989943", 8 | "Height": 125, 9 | "Width": 100 10 | }, 11 | "Animated" : false, 12 | "IDs": [116, 943, 234, 38793] 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /jsonexamples/small/flatadversarial.json: -------------------------------------------------------------------------------- 1 | { "\"Name": [ 116,"\\\"", 234, "true", false ], "t": 1.0e+10} 2 | -------------------------------------------------------------------------------- /jsonexamples/small/jsoniter_scala/README.md: -------------------------------------------------------------------------------- 1 | Files from https://github.com/plokhotnyuk/jsoniter-scala/tree/master/jsoniter-scala-benchmark/src/main/resources/com/github/plokhotnyuk/jsoniter_scala/benchmark 2 | 3 | See issue "Lower performance on small files": 4 | https://github.com/lemire/simdjson/issues/70 5 | -------------------------------------------------------------------------------- /jsonexamples/small/jsoniter_scala/twitter_api_compact_response.json: -------------------------------------------------------------------------------- 1 | [{"created_at":"Thu Apr 06 15:28:43 +0000 2017","id":850007368138018817,"id_str":"850007368138018817","text":"RT @TwitterDev: 1/ Today we’re sharing our vision for the future of the Twitter API platform!\nhttps://t.co/XweGngmxlP","truncated":false,"entities":{"user_mentions":[{"screen_name":"TwitterDev","name":"TwitterDev","id":2244994945,"id_str":"2244994945","indices":[3,14]}],"urls":[{"url":"https://t.co/XweGngmxlP","expanded_url":"https://cards.twitter.com/cards/18ce53wgo4h/3xo1c","display_url":"cards.twitter.com/cards/18ce53wg…","indices":[94,117]}]},"source":"Twitter Web Client","user":{"id":6253282,"id_str":"6253282","name":"Twitter API","screen_name":"twitterapi","location":"San Francisco, CA","description":"The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API. Don't get an answer? It's on my website.","url":"http://t.co/78pYTvWfJd","entities":{"url":{"urls":[{"url":"http://t.co/78pYTvWfJd","expanded_url":"https://dev.twitter.com","display_url":"dev.twitter.com","indices":[0,22]}]},"description":{}},"protected":false,"followers_count":6172353,"friends_count":46,"listed_count":13091,"created_at":"Wed May 23 06:01:13 +0000 2007","favourites_count":26,"utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":true,"statuses_count":3583,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/656927849/miyt9dpjz77sc0w3d4vj.png","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/656927849/miyt9dpjz77sc0w3d4vj.png","profile_background_tile":true,"profile_image_url":"http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/6253282/1431474710","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false,"translator_type":"regular"},"retweeted_status":{"created_at":"Thu Apr 06 15:24:15 +0000 2017","id":850006245121695744,"id_str":"850006245121695744","text":"1/ Today we’re sharing our vision for the future of the Twitter API platform!\nhttps://t.co/XweGngmxlP","truncated":false,"entities":{"urls":[{"url":"https://t.co/XweGngmxlP","expanded_url":"https://cards.twitter.com/cards/18ce53wgo4h/3xo1c","display_url":"cards.twitter.com/cards/18ce53wg…","indices":[78,101]}]},"source":"Twitter Web Client","user":{"id":2244994945,"id_str":"2244994945","name":"TwitterDev","screen_name":"TwitterDev","location":"Internet","description":"Your official source for Twitter Platform news, updates & events. Need technical help? Visit https://t.co/mGHnxZCxkt ⌨️ #TapIntoTwitter","url":"https://t.co/66w26cua1O","entities":{"url":{"urls":[{"url":"https://t.co/66w26cua1O","expanded_url":"https://dev.twitter.com/","display_url":"dev.twitter.com","indices":[0,23]}]},"description":{"urls":[{"url":"https://t.co/mGHnxZCxkt","expanded_url":"https://twittercommunity.com/","display_url":"twittercommunity.com","indices":[93,116]}]}},"protected":false,"followers_count":465425,"friends_count":1523,"listed_count":1168,"created_at":"Sat Dec 14 04:35:55 +0000 2013","favourites_count":2098,"utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":true,"statuses_count":3031,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"FFFFFF","profile_background_image_url":"http://abs.twimg.com/images/themes/theme1/bg.png","profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme1/bg.png","profile_background_tile":false,"profile_image_url":"http://pbs.twimg.com/profile_images/530814764687949824/npQQVkq8_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/530814764687949824/npQQVkq8_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/2244994945/1396995246","profile_link_color":"0084B4","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false,"translator_type":"regular"},"is_quote_status":false,"retweet_count":284,"favorite_count":399,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"is_quote_status":false,"retweet_count":284,"favorite_count":0,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},{"created_at":"Mon Apr 03 16:09:50 +0000 2017","id":848930551989915648,"id_str":"848930551989915648","text":"RT @TwitterMktg: Starting today, businesses can request and share locations when engaging with people in Direct Messages. https://t.co/rpYn…","truncated":false,"entities":{"user_mentions":[{"screen_name":"TwitterMktg","name":"Twitter Marketing","id":357750891,"id_str":"357750891","indices":[3,15]}]},"source":"Twitter Web Client","user":{"id":6253282,"id_str":"6253282","name":"Twitter API","screen_name":"twitterapi","location":"San Francisco, CA","description":"The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API. Don't get an answer? It's on my website.","url":"http://t.co/78pYTvWfJd","entities":{"url":{"urls":[{"url":"http://t.co/78pYTvWfJd","expanded_url":"https://dev.twitter.com","display_url":"dev.twitter.com","indices":[0,22]}]},"description":{}},"protected":false,"followers_count":6172353,"friends_count":46,"listed_count":13091,"created_at":"Wed May 23 06:01:13 +0000 2007","favourites_count":26,"utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":true,"statuses_count":3583,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/656927849/miyt9dpjz77sc0w3d4vj.png","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/656927849/miyt9dpjz77sc0w3d4vj.png","profile_background_tile":true,"profile_image_url":"http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/6253282/1431474710","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false,"translator_type":"regular"},"retweeted_status":{"created_at":"Mon Apr 03 16:05:05 +0000 2017","id":848929357519241216,"id_str":"848929357519241216","text":"Starting today, businesses can request and share locations when engaging with people in Direct Messages. https://t.co/rpYndqWfQw","truncated":false,"entities":{"urls":[{"url":"https://t.co/rpYndqWfQw","expanded_url":"https://cards.twitter.com/cards/5wzucr/3x700","display_url":"cards.twitter.com/cards/5wzucr/3…","indices":[105,128]}]},"source":"Twitter Ads","user":{"id":357750891,"id_str":"357750891","name":"Twitter Marketing","screen_name":"TwitterMktg","location":"Twitter HQ ","description":"Twitter’s place for marketers, agencies, and creative thinkers ⭐ Bringing you insights, news, updates, and inspiration. Visit @TwitterAdsHelp for Ads support.","url":"https://t.co/Tfo4moo92y","entities":{"url":{"urls":[{"url":"https://t.co/Tfo4moo92y","expanded_url":"https://marketing.twitter.com","display_url":"marketing.twitter.com","indices":[0,23]}]},"description":{}},"protected":false,"followers_count":924546,"friends_count":661,"listed_count":3893,"created_at":"Thu Aug 18 21:08:15 +0000 2011","favourites_count":1934,"utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":true,"statuses_count":6329,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/662767273/jvmxdpdrplhxcw8yvkv2.png","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/662767273/jvmxdpdrplhxcw8yvkv2.png","profile_background_tile":true,"profile_image_url":"http://pbs.twimg.com/profile_images/800953549697888256/UlXXL5h5_normal.jpg","profile_image_url_https":"https://pbs.twimg.com/profile_images/800953549697888256/UlXXL5h5_normal.jpg","profile_banner_url":"https://pbs.twimg.com/profile_banners/357750891/1487188210","profile_link_color":"19CF86","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false,"translator_type":"none"},"is_quote_status":false,"retweet_count":111,"favorite_count":162,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"is_quote_status":false,"retweet_count":111,"favorite_count":0,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"}] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_double_huge_neg_exp.json: -------------------------------------------------------------------------------- 1 | [123.456e-789] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_huge_exp.json: -------------------------------------------------------------------------------- 1 | [0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_neg_int_huge_exp.json: -------------------------------------------------------------------------------- 1 | [-1e+9999] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_pos_double_huge_exp.json: -------------------------------------------------------------------------------- 1 | [1.5e+9999] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_real_neg_overflow.json: -------------------------------------------------------------------------------- 1 | [-123123e100000] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_real_pos_overflow.json: -------------------------------------------------------------------------------- 1 | [123123e100000] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_real_underflow.json: -------------------------------------------------------------------------------- 1 | [123e-10000000] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_too_big_neg_int.json: -------------------------------------------------------------------------------- 1 | [-123123123123123123123123123123] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_too_big_pos_int.json: -------------------------------------------------------------------------------- 1 | [100000000000000000000] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_number_very_big_negative_int.json: -------------------------------------------------------------------------------- 1 | [-237462374673276894279832749832423479823246327846] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_object_key_lone_2nd_surrogate.json: -------------------------------------------------------------------------------- 1 | {"\uDFAA":0} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_1st_surrogate_but_2nd_missing.json: -------------------------------------------------------------------------------- 1 | ["\uDADA"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json: -------------------------------------------------------------------------------- 1 | ["\uD888\u1234"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_UTF-16LE_with_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_UTF-16LE_with_BOM.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_UTF-8_invalid_sequence.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_UTF-8_invalid_sequence.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_UTF8_surrogate_U+D800.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_UTF8_surrogate_U+D800.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\n"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_incomplete_surrogate_pair.json: -------------------------------------------------------------------------------- 1 | ["\uDd1ea"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_incomplete_surrogates_escape_valid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800\n"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_invalid_lonely_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\ud800"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_invalid_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\ud800abc"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_invalid_utf-8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_invalid_utf-8.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_inverted_surrogates_U+1D11E.json: -------------------------------------------------------------------------------- 1 | ["\uDd1e\uD834"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_iso_latin_1.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_iso_latin_1.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_lone_second_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\uDFAA"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_lone_utf8_continuation_byte.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_lone_utf8_continuation_byte.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_not_in_unicode_range.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_not_in_unicode_range.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_overlong_sequence_2_bytes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_overlong_sequence_2_bytes.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_overlong_sequence_6_bytes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_overlong_sequence_6_bytes.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_overlong_sequence_6_bytes_null.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_overlong_sequence_6_bytes_null.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_truncated-utf-8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_truncated-utf-8.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_utf16BE_no_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_utf16BE_no_BOM.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_string_utf16LE_no_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/i_string_utf16LE_no_BOM.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_structure_500_nested_arrays.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/i_structure_UTF-8_BOM_empty_object.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_1_true_without_comma.json: -------------------------------------------------------------------------------- 1 | [1 true] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_a_invalid_utf8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_array_a_invalid_utf8.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_colon_instead_of_comma.json: -------------------------------------------------------------------------------- 1 | ["": 1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_comma_after_close.json: -------------------------------------------------------------------------------- 1 | [""], -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_comma_and_number.json: -------------------------------------------------------------------------------- 1 | [,1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_double_comma.json: -------------------------------------------------------------------------------- 1 | [1,,2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_double_extra_comma.json: -------------------------------------------------------------------------------- 1 | ["x",,] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_extra_close.json: -------------------------------------------------------------------------------- 1 | ["x"]] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_extra_comma.json: -------------------------------------------------------------------------------- 1 | ["",] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_incomplete.json: -------------------------------------------------------------------------------- 1 | ["x" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_incomplete_invalid_value.json: -------------------------------------------------------------------------------- 1 | [x -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_inner_array_no_comma.json: -------------------------------------------------------------------------------- 1 | [3[4]] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_invalid_utf8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_array_invalid_utf8.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_items_separated_by_semicolon.json: -------------------------------------------------------------------------------- 1 | [1:2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_just_comma.json: -------------------------------------------------------------------------------- 1 | [,] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_just_minus.json: -------------------------------------------------------------------------------- 1 | [-] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_missing_value.json: -------------------------------------------------------------------------------- 1 | [ , ""] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_newlines_unclosed.json: -------------------------------------------------------------------------------- 1 | ["a", 2 | 4 3 | ,1, -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_number_and_comma.json: -------------------------------------------------------------------------------- 1 | [1,] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_number_and_several_commas.json: -------------------------------------------------------------------------------- 1 | [1,,] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_spaces_vertical_tab_formfeed.json: -------------------------------------------------------------------------------- 1 | [" a"\f] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_star_inside.json: -------------------------------------------------------------------------------- 1 | [*] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_unclosed.json: -------------------------------------------------------------------------------- 1 | ["" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_unclosed_trailing_comma.json: -------------------------------------------------------------------------------- 1 | [1, -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_unclosed_with_new_lines.json: -------------------------------------------------------------------------------- 1 | [1, 2 | 1 3 | ,1 -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_array_unclosed_with_object_inside.json: -------------------------------------------------------------------------------- 1 | [{} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_incomplete_false.json: -------------------------------------------------------------------------------- 1 | [fals] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_incomplete_null.json: -------------------------------------------------------------------------------- 1 | [nul] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_incomplete_true.json: -------------------------------------------------------------------------------- 1 | [tru] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_multidigit_number_then_00.json: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_++.json: -------------------------------------------------------------------------------- 1 | [++1234] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_+1.json: -------------------------------------------------------------------------------- 1 | [+1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_+Inf.json: -------------------------------------------------------------------------------- 1 | [+Inf] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_-01.json: -------------------------------------------------------------------------------- 1 | [-01] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_-1.0..json: -------------------------------------------------------------------------------- 1 | [-1.0.] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_-2..json: -------------------------------------------------------------------------------- 1 | [-2.] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_-NaN.json: -------------------------------------------------------------------------------- 1 | [-NaN] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_.-1.json: -------------------------------------------------------------------------------- 1 | [.-1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_.2e-3.json: -------------------------------------------------------------------------------- 1 | [.2e-3] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0.1.2.json: -------------------------------------------------------------------------------- 1 | [0.1.2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0.3e+.json: -------------------------------------------------------------------------------- 1 | [0.3e+] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0.3e.json: -------------------------------------------------------------------------------- 1 | [0.3e] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0.e1.json: -------------------------------------------------------------------------------- 1 | [0.e1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0_capital_E+.json: -------------------------------------------------------------------------------- 1 | [0E+] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0_capital_E.json: -------------------------------------------------------------------------------- 1 | [0E] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0e+.json: -------------------------------------------------------------------------------- 1 | [0e+] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_0e.json: -------------------------------------------------------------------------------- 1 | [0e] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_1.0e+.json: -------------------------------------------------------------------------------- 1 | [1.0e+] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_1.0e-.json: -------------------------------------------------------------------------------- 1 | [1.0e-] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_1.0e.json: -------------------------------------------------------------------------------- 1 | [1.0e] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_1_000.json: -------------------------------------------------------------------------------- 1 | [1 000.0] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_1eE2.json: -------------------------------------------------------------------------------- 1 | [1eE2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_2.e+3.json: -------------------------------------------------------------------------------- 1 | [2.e+3] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_2.e-3.json: -------------------------------------------------------------------------------- 1 | [2.e-3] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_2.e3.json: -------------------------------------------------------------------------------- 1 | [2.e3] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_9.e+.json: -------------------------------------------------------------------------------- 1 | [9.e+] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_Inf.json: -------------------------------------------------------------------------------- 1 | [Inf] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_NaN.json: -------------------------------------------------------------------------------- 1 | [NaN] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_U+FF11_fullwidth_digit_one.json: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_expression.json: -------------------------------------------------------------------------------- 1 | [1+2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_hex_1_digit.json: -------------------------------------------------------------------------------- 1 | [0x1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_hex_2_digits.json: -------------------------------------------------------------------------------- 1 | [0x42] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_infinity.json: -------------------------------------------------------------------------------- 1 | [Infinity] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_invalid+-.json: -------------------------------------------------------------------------------- 1 | [0e+-1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_invalid-negative-real.json: -------------------------------------------------------------------------------- 1 | [-123.123foo] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_invalid-utf-8-in-bigger-int.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_number_invalid-utf-8-in-bigger-int.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_invalid-utf-8-in-exponent.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_number_invalid-utf-8-in-exponent.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_invalid-utf-8-in-int.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_number_invalid-utf-8-in-int.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_minus_infinity.json: -------------------------------------------------------------------------------- 1 | [-Infinity] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_minus_sign_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | [-foo] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_minus_space_1.json: -------------------------------------------------------------------------------- 1 | [- 1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_neg_int_starting_with_zero.json: -------------------------------------------------------------------------------- 1 | [-012] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_neg_real_without_int_part.json: -------------------------------------------------------------------------------- 1 | [-.123] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_neg_with_garbage_at_end.json: -------------------------------------------------------------------------------- 1 | [-1x] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_real_garbage_after_e.json: -------------------------------------------------------------------------------- 1 | [1ea] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_real_with_invalid_utf8_after_e.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_number_real_with_invalid_utf8_after_e.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_real_without_fractional_part.json: -------------------------------------------------------------------------------- 1 | [1.] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_starting_with_dot.json: -------------------------------------------------------------------------------- 1 | [.123] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_with_alpha.json: -------------------------------------------------------------------------------- 1 | [1.2a-3] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_with_alpha_char.json: -------------------------------------------------------------------------------- 1 | [1.8011670033376514H-308] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_number_with_leading_zero.json: -------------------------------------------------------------------------------- 1 | [012] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_bad_value.json: -------------------------------------------------------------------------------- 1 | ["x", truth] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_bracket_key.json: -------------------------------------------------------------------------------- 1 | {[: "x"} 2 | -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_comma_instead_of_colon.json: -------------------------------------------------------------------------------- 1 | {"x", null} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_double_colon.json: -------------------------------------------------------------------------------- 1 | {"x"::"b"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_emoji.json: -------------------------------------------------------------------------------- 1 | {🇨🇭} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_garbage_at_end.json: -------------------------------------------------------------------------------- 1 | {"a":"a" 123} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_key_with_single_quotes.json: -------------------------------------------------------------------------------- 1 | {key: 'value'} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_missing_colon.json: -------------------------------------------------------------------------------- 1 | {"a" b} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_missing_key.json: -------------------------------------------------------------------------------- 1 | {:"b"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_missing_semicolon.json: -------------------------------------------------------------------------------- 1 | {"a" "b"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_missing_value.json: -------------------------------------------------------------------------------- 1 | {"a": -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_no-colon.json: -------------------------------------------------------------------------------- 1 | {"a" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_non_string_key.json: -------------------------------------------------------------------------------- 1 | {1:1} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_non_string_key_but_huge_number_instead.json: -------------------------------------------------------------------------------- 1 | {9999E9999:1} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_repeated_null_null.json: -------------------------------------------------------------------------------- 1 | {null:null,null:null} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_several_trailing_commas.json: -------------------------------------------------------------------------------- 1 | {"id":0,,,,,} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_single_quote.json: -------------------------------------------------------------------------------- 1 | {'a':0} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_trailing_comma.json: -------------------------------------------------------------------------------- 1 | {"id":0,} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_trailing_comment.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/**/ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_trailing_comment_open.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/**// -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_trailing_comment_slash_open.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}// -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_trailing_comment_slash_open_incomplete.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_two_commas_in_a_row.json: -------------------------------------------------------------------------------- 1 | {"a":"b",,"c":"d"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_unquoted_key.json: -------------------------------------------------------------------------------- 1 | {a: "b"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_unterminated-value.json: -------------------------------------------------------------------------------- 1 | {"a":"a -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_with_single_string.json: -------------------------------------------------------------------------------- 1 | { "foo" : "bar", "a" } -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_object_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}# -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_single_space.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_1_surrogate_then_escape.json: -------------------------------------------------------------------------------- 1 | ["\uD800\"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_1_surrogate_then_escape_u.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_1_surrogate_then_escape_u1.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u1"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_1_surrogate_then_escape_u1x.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u1x"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_accentuated_char_no_quotes.json: -------------------------------------------------------------------------------- 1 | [é] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_backslash_00.json: -------------------------------------------------------------------------------- 1 | ["\"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_escape_x.json: -------------------------------------------------------------------------------- 1 | ["\x00"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_escaped_backslash_bad.json: -------------------------------------------------------------------------------- 1 | ["\\\"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_escaped_ctrl_char_tab.json: -------------------------------------------------------------------------------- 1 | ["\ "] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_escaped_emoji.json: -------------------------------------------------------------------------------- 1 | ["\🌀"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_incomplete_escape.json: -------------------------------------------------------------------------------- 1 | ["\"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_incomplete_escaped_character.json: -------------------------------------------------------------------------------- 1 | ["\u00A"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_incomplete_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\uD834\uDd"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_incomplete_surrogate_escape_invalid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800\x"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_invalid-utf-8-in-escape.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_string_invalid-utf-8-in-escape.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_invalid_backslash_esc.json: -------------------------------------------------------------------------------- 1 | ["\a"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_invalid_unicode_escape.json: -------------------------------------------------------------------------------- 1 | ["\uqqqq"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_invalid_utf8_after_escape.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_string_invalid_utf8_after_escape.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_leading_uescaped_thinspace.json: -------------------------------------------------------------------------------- 1 | [\u0020"asd"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_no_quotes_with_bad_escape.json: -------------------------------------------------------------------------------- 1 | [\n] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_single_doublequote.json: -------------------------------------------------------------------------------- 1 | " -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_single_quote.json: -------------------------------------------------------------------------------- 1 | ['single quote'] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_single_string_no_double_quotes.json: -------------------------------------------------------------------------------- 1 | abc -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_start_escape_unclosed.json: -------------------------------------------------------------------------------- 1 | ["\ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_unescaped_crtl_char.json: -------------------------------------------------------------------------------- 1 | ["aa"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_unescaped_newline.json: -------------------------------------------------------------------------------- 1 | ["new 2 | line"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_unescaped_tab.json: -------------------------------------------------------------------------------- 1 | [" "] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_unicode_CapitalU.json: -------------------------------------------------------------------------------- 1 | "\UA66D" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_string_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | ""x -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_U+2060_word_joined.json: -------------------------------------------------------------------------------- 1 | [⁠] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_UTF8_BOM_no_data.json: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_angle_bracket_..json: -------------------------------------------------------------------------------- 1 | <.> -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_angle_bracket_null.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_array_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | [1]x -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_array_with_extra_array_close.json: -------------------------------------------------------------------------------- 1 | [1]] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_array_with_unclosed_string.json: -------------------------------------------------------------------------------- 1 | ["asd] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_ascii-unicode-identifier.json: -------------------------------------------------------------------------------- 1 | aå -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_capitalized_True.json: -------------------------------------------------------------------------------- 1 | [True] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_close_unopened_array.json: -------------------------------------------------------------------------------- 1 | 1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_comma_instead_of_closing_brace.json: -------------------------------------------------------------------------------- 1 | {"x": true, -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_double_array.json: -------------------------------------------------------------------------------- 1 | [][] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_end_array.json: -------------------------------------------------------------------------------- 1 | ] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_incomplete_UTF8_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_structure_incomplete_UTF8_BOM.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_lone-invalid-utf-8.json: -------------------------------------------------------------------------------- 1 | � -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_lone-open-bracket.json: -------------------------------------------------------------------------------- 1 | [ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_no_data.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazyxman/simdjson_php/9a2745669fea733a40f9443b1a793846d0759b89/jsonexamples/test_parsing/n_structure_no_data.json -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_null-byte-outside-string.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_number_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | 2@ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_object_followed_by_closing_object.json: -------------------------------------------------------------------------------- 1 | {}} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_object_unclosed_no_value.json: -------------------------------------------------------------------------------- 1 | {"": -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_object_with_comment.json: -------------------------------------------------------------------------------- 1 | {"a":/*comment*/"b"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_object_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | {"a": true} "x" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_array_apostrophe.json: -------------------------------------------------------------------------------- 1 | [' -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_array_comma.json: -------------------------------------------------------------------------------- 1 | [, -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_array_open_object.json: -------------------------------------------------------------------------------- 1 | [{ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_array_open_string.json: -------------------------------------------------------------------------------- 1 | ["a -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_array_string.json: -------------------------------------------------------------------------------- 1 | ["a" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_object.json: -------------------------------------------------------------------------------- 1 | { -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_object_close_array.json: -------------------------------------------------------------------------------- 1 | {] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_object_comma.json: -------------------------------------------------------------------------------- 1 | {, -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_object_open_array.json: -------------------------------------------------------------------------------- 1 | {[ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_object_open_string.json: -------------------------------------------------------------------------------- 1 | {"a -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_object_string_with_apostrophes.json: -------------------------------------------------------------------------------- 1 | {'a' -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_open_open.json: -------------------------------------------------------------------------------- 1 | ["\{["\{["\{["\{ -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_single_eacute.json: -------------------------------------------------------------------------------- 1 | � -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_single_star.json: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_trailing_#.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}#{} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_uescaped_LF_before_string.json: -------------------------------------------------------------------------------- 1 | [\u000A""] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_unclosed_array.json: -------------------------------------------------------------------------------- 1 | [1 -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_unclosed_array_partial_null.json: -------------------------------------------------------------------------------- 1 | [ false, nul -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_unclosed_array_unfinished_false.json: -------------------------------------------------------------------------------- 1 | [ true, fals -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_unclosed_array_unfinished_true.json: -------------------------------------------------------------------------------- 1 | [ false, tru -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_unclosed_object.json: -------------------------------------------------------------------------------- 1 | {"asd":"asd" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_unicode-identifier.json: -------------------------------------------------------------------------------- 1 | å -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_whitespace_U+2060_word_joiner.json: -------------------------------------------------------------------------------- 1 | [⁠] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/n_structure_whitespace_formfeed.json: -------------------------------------------------------------------------------- 1 | [ ] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_arraysWithSpaces.json: -------------------------------------------------------------------------------- 1 | [[] ] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_empty-string.json: -------------------------------------------------------------------------------- 1 | [""] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_empty.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_ending_with_newline.json: -------------------------------------------------------------------------------- 1 | ["a"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_false.json: -------------------------------------------------------------------------------- 1 | [false] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_heterogeneous.json: -------------------------------------------------------------------------------- 1 | [null, 1, "1", {}] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_null.json: -------------------------------------------------------------------------------- 1 | [null] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_with_1_and_newline.json: -------------------------------------------------------------------------------- 1 | [1 2 | ] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_with_leading_space.json: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_with_several_null.json: -------------------------------------------------------------------------------- 1 | [1,null,null,null,2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_array_with_trailing_space.json: -------------------------------------------------------------------------------- 1 | [2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number.json: -------------------------------------------------------------------------------- 1 | [123e65] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_0e+1.json: -------------------------------------------------------------------------------- 1 | [0e+1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_0e1.json: -------------------------------------------------------------------------------- 1 | [0e1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_after_space.json: -------------------------------------------------------------------------------- 1 | [ 4] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_double_close_to_zero.json: -------------------------------------------------------------------------------- 1 | [-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] 2 | -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_int_with_exp.json: -------------------------------------------------------------------------------- 1 | [20e1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_minus_zero.json: -------------------------------------------------------------------------------- 1 | [-0] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_negative_int.json: -------------------------------------------------------------------------------- 1 | [-123] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_negative_one.json: -------------------------------------------------------------------------------- 1 | [-1] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_negative_zero.json: -------------------------------------------------------------------------------- 1 | [-0] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_real_capital_e.json: -------------------------------------------------------------------------------- 1 | [1E22] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_real_capital_e_neg_exp.json: -------------------------------------------------------------------------------- 1 | [1E-2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_real_capital_e_pos_exp.json: -------------------------------------------------------------------------------- 1 | [1E+2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_real_exponent.json: -------------------------------------------------------------------------------- 1 | [123e45] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_real_fraction_exponent.json: -------------------------------------------------------------------------------- 1 | [123.456e78] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_real_neg_exp.json: -------------------------------------------------------------------------------- 1 | [1e-2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_real_pos_exponent.json: -------------------------------------------------------------------------------- 1 | [1e+2] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_simple_int.json: -------------------------------------------------------------------------------- 1 | [123] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_number_simple_real.json: -------------------------------------------------------------------------------- 1 | [123.456789] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object.json: -------------------------------------------------------------------------------- 1 | {"asd":"sdf", "dfg":"fgh"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_basic.json: -------------------------------------------------------------------------------- 1 | {"asd":"sdf"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_duplicated_key.json: -------------------------------------------------------------------------------- 1 | {"a":"b","a":"c"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_duplicated_key_and_value.json: -------------------------------------------------------------------------------- 1 | {"a":"b","a":"b"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_empty.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_empty_key.json: -------------------------------------------------------------------------------- 1 | {"":0} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_escaped_null_in_key.json: -------------------------------------------------------------------------------- 1 | {"foo\u0000bar": 42} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_extreme_numbers.json: -------------------------------------------------------------------------------- 1 | { "min": -1.0e+28, "max": 1.0e+28 } -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_long_strings.json: -------------------------------------------------------------------------------- 1 | {"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_simple.json: -------------------------------------------------------------------------------- 1 | {"a":[]} -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_string_unicode.json: -------------------------------------------------------------------------------- 1 | {"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_object_with_newlines.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b" 3 | } -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json: -------------------------------------------------------------------------------- 1 | ["\u0060\u012a\u12AB"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_accepted_surrogate_pair.json: -------------------------------------------------------------------------------- 1 | ["\uD801\udc37"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_accepted_surrogate_pairs.json: -------------------------------------------------------------------------------- 1 | ["\ud83d\ude39\ud83d\udc8d"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_allowed_escapes.json: -------------------------------------------------------------------------------- 1 | ["\"\\\/\b\f\n\r\t"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_backslash_and_u_escaped_zero.json: -------------------------------------------------------------------------------- 1 | ["\\u0000"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_backslash_doublequotes.json: -------------------------------------------------------------------------------- 1 | ["\""] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_comments.json: -------------------------------------------------------------------------------- 1 | ["a/*b*/c/*d//e"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_double_escape_a.json: -------------------------------------------------------------------------------- 1 | ["\\a"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_double_escape_n.json: -------------------------------------------------------------------------------- 1 | ["\\n"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_escaped_control_character.json: -------------------------------------------------------------------------------- 1 | ["\u0012"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_escaped_noncharacter.json: -------------------------------------------------------------------------------- 1 | ["\uFFFF"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_in_array.json: -------------------------------------------------------------------------------- 1 | ["asd"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_in_array_with_leading_space.json: -------------------------------------------------------------------------------- 1 | [ "asd"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_last_surrogates_1_and_2.json: -------------------------------------------------------------------------------- 1 | ["\uDBFF\uDFFF"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_nbsp_uescaped.json: -------------------------------------------------------------------------------- 1 | ["new\u00A0line"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json: -------------------------------------------------------------------------------- 1 | ["􏿿"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json: -------------------------------------------------------------------------------- 1 | ["￿"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_null_escape.json: -------------------------------------------------------------------------------- 1 | ["\u0000"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_one-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u002c"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_pi.json: -------------------------------------------------------------------------------- 1 | ["π"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json: -------------------------------------------------------------------------------- 1 | ["𛿿"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_simple_ascii.json: -------------------------------------------------------------------------------- 1 | ["asd "] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_space.json: -------------------------------------------------------------------------------- 1 | " " -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json: -------------------------------------------------------------------------------- 1 | ["\uD834\uDd1e"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_three-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u0821"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_two-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u0123"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_u+2028_line_sep.json: -------------------------------------------------------------------------------- 1 | ["
"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_u+2029_par_sep.json: -------------------------------------------------------------------------------- 1 | ["
"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_uEscape.json: -------------------------------------------------------------------------------- 1 | ["\u0061\u30af\u30EA\u30b9"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_uescaped_newline.json: -------------------------------------------------------------------------------- 1 | ["new\u000Aline"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unescaped_char_delete.json: -------------------------------------------------------------------------------- 1 | [""] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode.json: -------------------------------------------------------------------------------- 1 | ["\uA66D"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicodeEscapedBackslash.json: -------------------------------------------------------------------------------- 1 | ["\u005C"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_2.json: -------------------------------------------------------------------------------- 1 | ["⍂㈴⍂"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_U+10FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uDBFF\uDFFE"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_U+1FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uD83F\uDFFE"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json: -------------------------------------------------------------------------------- 1 | ["\u200B"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_U+2064_invisible_plus.json: -------------------------------------------------------------------------------- 1 | ["\u2064"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_U+FDD0_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uFDD0"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_U+FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uFFFE"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_unicode_escaped_double_quote.json: -------------------------------------------------------------------------------- 1 | ["\u0022"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_utf8.json: -------------------------------------------------------------------------------- 1 | ["€𝄞"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_string_with_del_character.json: -------------------------------------------------------------------------------- 1 | ["aa"] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_lonely_false.json: -------------------------------------------------------------------------------- 1 | false -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_lonely_int.json: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_lonely_negative_real.json: -------------------------------------------------------------------------------- 1 | -0.1 -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_lonely_null.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_lonely_string.json: -------------------------------------------------------------------------------- 1 | "asd" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_lonely_true.json: -------------------------------------------------------------------------------- 1 | true -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_string_empty.json: -------------------------------------------------------------------------------- 1 | "" -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_trailing_newline.json: -------------------------------------------------------------------------------- 1 | ["a"] 2 | -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_true_in_array.json: -------------------------------------------------------------------------------- 1 | [true] -------------------------------------------------------------------------------- /jsonexamples/test_parsing/y_structure_whitespace_array.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /php_simdjson.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | simdjson_php | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 2.0 of the Apache license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.apache.org/licenses/LICENSE-2.0.html | 9 | +----------------------------------------------------------------------+ 10 | | Author: Jinxi Wang <1054636713@qq.com> | 11 | +----------------------------------------------------------------------+ 12 | */ 13 | 14 | #ifndef PHP_SIMDJSON_H 15 | #define PHP_SIMDJSON_H 16 | 17 | /* 18 | * Error constant implementation notes: 19 | * 20 | * - 0 always means success, and non-0 is a failure condition. 21 | * - Prefix these with SIMDJSON_PHP_ERR_ to distinguish them from other values. 22 | * - The error codes (value or labels) belonging to the C simdjson project may change in the future. 23 | * 24 | * Maybe these should be exposed as extern const once there's a project that needs the other values. 25 | * For now, they're also exposed as `REGISTER_LONG_CONSTANT("SIMDJSON_ERR_" #errcode, (val), CONST_PERSISTENT)` 26 | */ 27 | #define SIMDJSON_PHP_ERR_SUCCESS 0 28 | #define SIMDJSON_PHP_ERR_INVALID_PHP_PROPERTY 255 29 | #define SIMDJSON_PHP_ERR_KEY_COUNT_NOT_COUNTABLE 254 30 | 31 | /* 32 | * Put all of the publicly visible functionality and macros into the same header file 33 | * (On windows, the include paths used by the c compiler may be different) 34 | */ 35 | #include "Zend/zend.h" 36 | #include "Zend/zend_portability.h" 37 | 38 | /* 39 | * All code in this header file should be changed to go within BEGIN_EXTERN_C/END_EXTERN_C macros 40 | * (both header definitions, and C++ declarations, including function implementations), 41 | * so that pecls written in C can use this functionality without separate C++ files to load bindings.h. 42 | * 43 | * This header file deliberately does not depend on other header files in this project, 44 | * to make including this header file easier for other PECLs (avoid include path issues) 45 | * 46 | * BEGIN_EXTERN_C is needed for symbols to be mangled using C rules instead of C++ rules in all includers. 47 | * (This macro can be used from both C and C++ source files) 48 | */ 49 | BEGIN_EXTERN_C() 50 | 51 | extern zend_module_entry simdjson_module_entry; 52 | #define phpext_simdjson_ptr &simdjson_module_entry 53 | 54 | #define PHP_SIMDJSON_VERSION "4.0.1dev" 55 | /** 56 | * PHP_SIMDJSON_VERSION_ID has the same format as PHP_VERSION_ID: Major version * 10000 + Minor version * 100 + Patch version. 57 | * This is meant for use by PECL extensions that depend on simdjson. 58 | * (e.g. 4.5.6dev and 4.5.6 would be 40506) 59 | */ 60 | #define PHP_SIMDJSON_VERSION_ID 40001 61 | 62 | #define SIMDJSON_SUPPORT_URL "https://github.com/crazyxman/simdjson_php" 63 | 64 | #define SIMDJSON_PARSE_DEFAULT_DEPTH 512 65 | 66 | /* 67 | * NOTE: Namespaces and references(&) are C++ only functionality. 68 | * To expose this functionality to other C PECLs, 69 | * switch to a forward struct declaration of a struct that only wraps simdjson::dom::parser 70 | */ 71 | struct simdjson_php_parser; 72 | 73 | ZEND_BEGIN_MODULE_GLOBALS(simdjson) 74 | /* 75 | * php::simdjson::parser pointer, constructed on first use with request-scope lifetime. 76 | * Note that in ZTS builds, the thread for each request will deliberately have different instances for each concurrently running request. 77 | * (The simdjson library is not thread safe) 78 | * 79 | * This is similar to php-src's ext/session session data storage. 80 | */ 81 | struct simdjson_php_parser *parser; 82 | ZEND_END_MODULE_GLOBALS(simdjson) 83 | 84 | PHP_MINIT_FUNCTION(simdjson); 85 | PHP_MSHUTDOWN_FUNCTION(simdjson); 86 | PHP_RINIT_FUNCTION(simdjson); 87 | PHP_RSHUTDOWN_FUNCTION(simdjson); 88 | PHP_MINFO_FUNCTION(simdjson); 89 | 90 | #ifdef ZTS 91 | #ifdef COMPILE_DL_SIMDJSON 92 | ZEND_TSRMLS_CACHE_EXTERN() 93 | #endif 94 | #endif 95 | 96 | /* Only the functions and variables defined with PHP_SIMDJSON_API can be loaded by other PECLs */ 97 | #ifdef PHP_WIN32 98 | # define PHP_SIMDJSON_API __declspec(dllexport) 99 | #elif defined(__GNUC__) && __GNUC__ >= 4 100 | # define PHP_SIMDJSON_API __attribute__ ((visibility("default"))) 101 | #else 102 | # define PHP_SIMDJSON_API /* nothing special */ 103 | #endif 104 | 105 | /** Defines 'class SimdJsonException' */ 106 | extern PHP_SIMDJSON_API zend_class_entry *simdjson_exception_ce; 107 | extern PHP_SIMDJSON_API zend_class_entry *simdjson_value_error_ce; 108 | 109 | /** 110 | * NOTE: Namespaces and references(&) and classes (instead of structs) are C++ only functionality. 111 | * 112 | * To expose this functionality to other C PECLs, 113 | * switch to a forward class declaration of a class that only wraps simdjson::dom::parser 114 | */ 115 | typedef uint8_t simdjson_php_error_code; 116 | 117 | /* NOTE: Callers should check if len is greater than 4GB - simdjson will always return a non zero error code for those */ 118 | 119 | /** 120 | * Parses the given string into a return code, using the default singleton parser. 121 | * 122 | * This must be called after simdjson's request initialization phase and before simdjson's request shutdown phase. 123 | * (e.g. PECLs should not use this during module or request initialization/shutdown) 124 | */ 125 | PHP_SIMDJSON_API simdjson_php_error_code php_simdjson_parse_default(const char *json, size_t len, zval *return_value, bool associative, size_t depth); 126 | 127 | /** 128 | * Checks if the given JSON is valid, using the default singleton parser. 129 | * Returns 0 if it is valid. 130 | */ 131 | PHP_SIMDJSON_API simdjson_php_error_code php_simdjson_validate_default(const char *json, size_t len, size_t depth); 132 | 133 | /** 134 | * Returns or creates the singleton parser used internally by simdjson (e.g. for the `php_simdjson_*_default()` methods). 135 | * (Thread-local in ZTS builds of PHP) 136 | * 137 | * Callers must NOT free this. 138 | */ 139 | PHP_SIMDJSON_API struct simdjson_php_parser *php_simdjson_get_default_singleton_parser(void); 140 | 141 | /* FIXME add php_simdjson_get_default_singleton_parser api */ 142 | /* FIXME add php_simdjson_decode_with_default_singleton_parser(return_value, json, len, bool associative) */ 143 | 144 | /** 145 | * Returns the error message corresponding to a given error code returned by a call to simdjson_php. 146 | */ 147 | PHP_SIMDJSON_API const char* php_simdjson_error_msg(simdjson_php_error_code code); 148 | /** 149 | * Throw a SimdJsonException with the provided error code and the corresponding error message. 150 | */ 151 | PHP_SIMDJSON_API void php_simdjson_throw_jsonexception(simdjson_php_error_code code); 152 | /** 153 | * Create a brand new parser instance. 154 | * 155 | * The caller must free it with php_simdjson_free_parser once it is no longer used. 156 | * 157 | * Callers may use this instead of the shared singleton parser when memory usage is a concern 158 | * (e.g. the PECLs are likely to be used load a string that's megabytes long in a long-lived php process) 159 | * 160 | * Callers should free this parser before or during the request shutdown phase. 161 | */ 162 | PHP_SIMDJSON_API struct simdjson_php_parser* php_simdjson_create_parser(void); 163 | /** 164 | * Release a parser **constructed by php_simdjson_create_parser** and all associated buffers. 165 | */ 166 | PHP_SIMDJSON_API void php_simdjson_free_parser(struct simdjson_php_parser* parser); 167 | /** 168 | * Returns 0 if the given json string is valid 169 | */ 170 | PHP_SIMDJSON_API simdjson_php_error_code php_simdjson_validate(struct simdjson_php_parser* parser, const char *json, size_t len, size_t depth); 171 | /** 172 | * Parses the given string into a return code. 173 | * 174 | * If the returned error code is 0, then return_value contains the parsed value. 175 | * If the returned error code is non-0, then return_value will not be initialized. 176 | */ 177 | PHP_SIMDJSON_API simdjson_php_error_code php_simdjson_parse(struct simdjson_php_parser* parser, const char *json, size_t len, zval *return_value, bool associative, size_t depth); 178 | /** 179 | * Parses the part of the given string at the json pointer 'key' into a PHP value at return_value 180 | * 181 | * If the returned error code is 0, then return_value contains the parsed value (or null). 182 | * If the returned error code is non-0, then return_value will not be initialized. 183 | * 184 | * - SIMDJSON_ERR_NO_SUCH_FIELD is returned if the json pointer 'key' is not found 185 | * - Other errors are returned for invalid json, etc. 186 | * 187 | * @see https://www.rfc-editor.org/rfc/rfc6901.html 188 | */ 189 | PHP_SIMDJSON_API simdjson_php_error_code php_simdjson_key_value(struct simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, bool associative, size_t depth); 190 | /** 191 | * Checks if the json pointer 'key' exists in the given json string. 192 | * 193 | * - 0 if the key exists 194 | * - NO_SUCH_FIELD if a field does not exist in an object 195 | * - INDEX_OUT_OF_BOUNDS if an array index is larger than an array length 196 | * - INCORRECT_TYPE if a non-integer is used to access an array 197 | * - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed 198 | * 199 | * @see https://www.rfc-editor.org/rfc/rfc6901.html 200 | */ 201 | PHP_SIMDJSON_API uint8_t php_simdjson_key_exists(struct simdjson_php_parser* parser, const char *json, size_t len, const char *key, size_t depth); 202 | /** 203 | * Count the keys of the given array/object at json pointer 'key' exists in the given json string. 204 | * 205 | * If the returned error code is 0, then the zval in return_value is overwritten with the key count using ZVAL_LONG. 206 | * - For arrays, this is the array size 207 | * - For objects, this is the object size 208 | * - For other values, this is 0 (when fail_if_uncountable is false) 209 | * 210 | * @see https://www.rfc-editor.org/rfc/rfc6901.html 211 | */ 212 | PHP_SIMDJSON_API simdjson_php_error_code php_simdjson_key_count(struct simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, size_t depth, bool fail_if_uncountable); 213 | 214 | END_EXTERN_C() 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /phpbench.json.dist: -------------------------------------------------------------------------------- 1 | { 2 | "bootstrap": "benchmark/vendor/autoload.php", 3 | "path": "benchmark/phpbench", 4 | "retry_threshold": 4, 5 | "reports": { 6 | "table": { 7 | "generator": "table", 8 | "cols": [ 9 | "benchmark", 10 | "subject", 11 | "groups", 12 | "mem_peak", 13 | "mean", 14 | "best", 15 | "diff" 16 | ], 17 | "sort": { 18 | "groups": "asc", 19 | "mean": "asc" 20 | } 21 | } 22 | }, 23 | "php_config": { 24 | "extension": [ "modules/simdjson.so" ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /simdjson.stub.php: -------------------------------------------------------------------------------- 1 | | 11 | +----------------------------------------------------------------------+ 12 | */ 13 | #ifndef SIMDJSON_PHP_BINDINGS_IMPL_H 14 | #define SIMDJSON_PHP_BINDINGS_IMPL_H 15 | 16 | #include "simdjson.h" 17 | 18 | // NOTE: Namespaces are C++ only functionality. 19 | // To expose this functionality to other C PECLs, 20 | // bindings.h exposes a forward class declaration of a class that only wraps simdjson::dom::parser 21 | struct simdjson_php_parser { 22 | public: 23 | simdjson::dom::parser parser; 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tests/32bit_support.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode test 32-bit 3 | --INI-- 4 | ; Older php versions used precision instead of serialize_precision for var_dump 5 | serialize_precision=-1 6 | precision=-1 7 | --SKIPIF-- 8 | = 8) echo "skip 32-bit platforms only\n"; ?> 9 | --FILE-- 10 | 15 | --EXPECT-- 16 | array(6) { 17 | [0]=> 18 | int(2147483647) 19 | [1]=> 20 | float(2147483648) 21 | [2]=> 22 | int(-2147483648) 23 | [3]=> 24 | float(-2147483649) 25 | [4]=> 26 | float(9.223372036854776E+18) 27 | [5]=> 28 | float(-9.223372036854776E+18) 29 | } 30 | -------------------------------------------------------------------------------- /tests/64bit_support.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode test 64-bit 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 9 | --EXPECT-- 10 | array(6) { 11 | [0]=> 12 | int(2147483647) 13 | [1]=> 14 | int(2147483648) 15 | [2]=> 16 | int(-2147483648) 17 | [3]=> 18 | int(-2147483649) 19 | [4]=> 20 | int(9223372036854775807) 21 | [5]=> 22 | int(-9223372036854775808) 23 | } 24 | -------------------------------------------------------------------------------- /tests/_files/result.json: -------------------------------------------------------------------------------- 1 | { 2 | "result": [ 3 | { 4 | "_key": "70614", 5 | "_id": "products/70614", 6 | "_rev": "_al3hU1K---", 7 | "Hello3": "World3" 8 | }, 9 | { 10 | "_key": "70616", 11 | "_id": "products/70616", 12 | "_rev": "_al3hU1K--A", 13 | "Hello4": "World4" 14 | } 15 | ], 16 | "hasMore": false, 17 | "count": 2, 18 | "cached": false, 19 | "extra": { 20 | "stats": { 21 | "writesExecuted": 0, 22 | "writesIgnored": 0, 23 | "scannedFull": 4, 24 | "scannedIndex": 0, 25 | "filtered": 0, 26 | "httpRequests": 0, 27 | "executionTime": 0.0001473426818847, 28 | "peakMemoryUsage": 2558 29 | }, 30 | "warnings": [] 31 | }, 32 | "error": false, 33 | "code": 201 34 | } -------------------------------------------------------------------------------- /tests/compat/001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Compat simdjson_decode() tests 3 | --SKIPIF-- 4 | ")); 21 | var_dump(simdjson_compat_decode(";")); 22 | var_dump(simdjson_compat_decode("руссиш")); 23 | var_dump(simdjson_compat_decode("blah")); 24 | var_dump(simdjson_compat_decode('{ "test": { "foo": "bar" } }')); 25 | var_dump(simdjson_compat_decode('{ "test": { "foo": "" } }')); 26 | var_dump(simdjson_compat_decode('{ "": { "foo": "" } }')); 27 | var_dump(simdjson_compat_decode('{ "": { "": "" } }')); 28 | var_dump(simdjson_compat_decode('{ "": { "": "" }')); 29 | var_dump(simdjson_compat_decode('{ "": "": "" } }')); 30 | 31 | ?> 32 | --EXPECTF-- 33 | NULL 34 | NULL 35 | NULL 36 | NULL 37 | NULL 38 | NULL 39 | NULL 40 | NULL 41 | NULL 42 | object(stdClass)#%d (1) { 43 | ["test"]=> 44 | object(stdClass)#%d (1) { 45 | ["foo"]=> 46 | string(3) "bar" 47 | } 48 | } 49 | object(stdClass)#%d (1) { 50 | ["test"]=> 51 | object(stdClass)#%d (1) { 52 | ["foo"]=> 53 | string(0) "" 54 | } 55 | } 56 | object(stdClass)#%d (1) { 57 | [""]=> 58 | object(stdClass)#%d (1) { 59 | ["foo"]=> 60 | string(0) "" 61 | } 62 | } 63 | object(stdClass)#%d (1) { 64 | [""]=> 65 | object(stdClass)#%d (1) { 66 | [""]=> 67 | string(0) "" 68 | } 69 | } 70 | NULL 71 | NULL 72 | -------------------------------------------------------------------------------- /tests/compat/bug41067.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #41067 compat test 3 | --FILE-- 4 | 11 | --EXPECT-- 12 | f09d8480 13 | END 14 | -------------------------------------------------------------------------------- /tests/compat/bug41504.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #41504 compat (json_decode() converts empty array keys to "_empty_") 3 | --FILE-- 4 | 12 | --EXPECT-- 13 | array(1) { 14 | [""]=> 15 | string(5) "value" 16 | } 17 | array(2) { 18 | [""]=> 19 | string(5) "value" 20 | ["key"]=> 21 | string(5) "value" 22 | } 23 | array(2) { 24 | ["key"]=> 25 | string(5) "value" 26 | [""]=> 27 | string(5) "value" 28 | } 29 | Done 30 | -------------------------------------------------------------------------------- /tests/compat/bug45791.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #45791 compat (json_decode() does not handle number 0e0) 3 | --FILE-- 4 | 9 | --EXPECT-- 10 | object(stdClass)#1 (1) { 11 | ["zero"]=> 12 | float(0) 13 | } 14 | -------------------------------------------------------------------------------- /tests/compat/bug47644.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #47644 compat (valid large integers are truncated) 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | array(1) { 19 | [0]=> 20 | int(10000000000000000) 21 | } 22 | array(1) { 23 | [0]=> 24 | int(10000000000000001) 25 | } 26 | array(1) { 27 | [0]=> 28 | int(10000000000000002) 29 | } 30 | array(1) { 31 | [0]=> 32 | int(10000000000000003) 33 | } 34 | array(1) { 35 | [0]=> 36 | int(10000000000000004) 37 | } 38 | array(1) { 39 | [0]=> 40 | int(10000000000000005) 41 | } 42 | Done 43 | -------------------------------------------------------------------------------- /tests/compat/bug50224.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | bug #50224 compat (json_encode() does not always encode a float as a float) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | serialize_precision=-1 7 | --FILE-- 8 | 12.0, 'integer' => 12), JSON_PRESERVE_ZERO_FRACTION)); 16 | 17 | echo "\n* Testing encode/decode symmetry\n\n"; 18 | 19 | var_dump(simdjson_decode(json_encode(12.3, JSON_PRESERVE_ZERO_FRACTION))); 20 | var_dump(simdjson_decode(json_encode(12, JSON_PRESERVE_ZERO_FRACTION))); 21 | var_dump(simdjson_decode(json_encode(12.0, JSON_PRESERVE_ZERO_FRACTION))); 22 | var_dump(simdjson_decode(json_encode(0.0, JSON_PRESERVE_ZERO_FRACTION))); 23 | var_dump(simdjson_decode(json_encode(array(12, 12.0, 12.3), JSON_PRESERVE_ZERO_FRACTION))); 24 | var_dump(simdjson_decode(json_encode((object)array('float' => 12.0, 'integer' => 12), JSON_PRESERVE_ZERO_FRACTION))); 25 | var_dump(simdjson_decode(json_encode((object)array('float' => 12.0, 'integer' => 12), JSON_PRESERVE_ZERO_FRACTION), true)); 26 | ?> 27 | --EXPECTF-- 28 | * Testing JSON output 29 | 30 | string(4) "12.3" 31 | string(2) "12" 32 | string(4) "12.0" 33 | string(3) "0.0" 34 | string(14) "[12,12.0,12.3]" 35 | string(27) "{"float":12.0,"integer":12}" 36 | 37 | * Testing encode/decode symmetry 38 | 39 | float(12.3) 40 | int(12) 41 | float(12) 42 | float(0) 43 | array(3) { 44 | [0]=> 45 | int(12) 46 | [1]=> 47 | float(12) 48 | [2]=> 49 | float(12.3) 50 | } 51 | object(stdClass)#%d (2) { 52 | ["float"]=> 53 | float(12) 54 | ["integer"]=> 55 | int(12) 56 | } 57 | array(2) { 58 | ["float"]=> 59 | float(12) 60 | ["integer"]=> 61 | int(12) 62 | } 63 | -------------------------------------------------------------------------------- /tests/compat/bug62010.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #62010 compat (json_decode produces invalid byte-sequences) 3 | --FILE-- 4 | getMessage()); 10 | } 11 | ?> 12 | --EXPECT-- 13 | Caught SimdJsonException: Problem while parsing a string -------------------------------------------------------------------------------- /tests/compat/bug64874_part1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Whitespace part of bug #64874 compat ("json_decode handles whitespace and case-sensitivity incorrectly") 3 | --FILE-- 4 | 42 | --EXPECT-- 43 | bool(true) 44 | 45 | bool(true) 46 | 47 | bool(true) 48 | 49 | bool(true) 50 | 51 | bool(true) 52 | 53 | bool(true) 54 | 55 | bool(true) 56 | 57 | bool(true) 58 | 59 | bool(true) 60 | 61 | bool(true) 62 | 63 | bool(true) 64 | 65 | bool(true) 66 | 67 | bool(true) 68 | 69 | bool(true) 70 | 71 | bool(true) 72 | 73 | bool(true) 74 | 75 | bool(true) 76 | 77 | bool(true) 78 | 79 | bool(true) 80 | 81 | bool(true) 82 | 83 | bool(true) 84 | 85 | bool(true) 86 | 87 | bool(true) 88 | 89 | bool(true) 90 | 91 | Done 92 | -------------------------------------------------------------------------------- /tests/compat/bug64874_part2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Case-sensitivity part of bug #64874 compat ("json_decode handles whitespace and case-sensitivity incorrectly") 3 | --FILE-- 4 | getMessage()); 10 | } 11 | } 12 | 13 | // Only lowercase should work 14 | decode('true'); 15 | decode('True'); 16 | decode('[true]'); 17 | decode('[True]'); 18 | echo PHP_EOL; 19 | 20 | decode('false'); 21 | decode('False'); 22 | decode('[false]'); 23 | decode('[False]'); 24 | echo PHP_EOL; 25 | 26 | decode('null'); 27 | decode('Null'); 28 | decode('[null]'); 29 | decode('[Null]'); 30 | echo PHP_EOL; 31 | 32 | echo "Done\n"; 33 | ?> 34 | --EXPECT-- 35 | bool(true) 36 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 37 | array(1) { 38 | [0]=> 39 | bool(true) 40 | } 41 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 42 | 43 | bool(false) 44 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 45 | array(1) { 46 | [0]=> 47 | bool(false) 48 | } 49 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 50 | 51 | NULL 52 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 53 | array(1) { 54 | [0]=> 55 | NULL 56 | } 57 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 58 | 59 | Done -------------------------------------------------------------------------------- /tests/compat/bug68546.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #68546 compat (json_decode() Fatal error: Cannot access property started with '\0') 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getCode(), $e->getMessage()); 12 | } 13 | try { 14 | var_dump(simdjson_decode('[{"key1": 0, "\u0000": 1}]')); 15 | } catch (RuntimeException $e) { 16 | printf("Caught %s: %d %s\n", get_class($e), $e->getCode(), $e->getMessage()); 17 | } 18 | echo "Arrays allow empty keys\n"; 19 | // var_export has trailing whitespace and var_dump emits a raw null byte. 20 | // Just use json for plain text, it's enabled in CI 21 | echo json_encode(simdjson_decode('{"key": {"\u0000": "aa"}}', true)), "\n"; 22 | 23 | echo "Done\n"; 24 | ?> 25 | --EXPECT-- 26 | Caught SimdJsonException: 255 Invalid property name 27 | Caught SimdJsonException: 255 Invalid property name 28 | Arrays allow empty keys 29 | {"key":{"\u0000":"aa"}} 30 | Done -------------------------------------------------------------------------------- /tests/compat/bug68817.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #68817 compat (Null pointer deference) 3 | --FILE-- 4 | 9 | --EXPECT-- 10 | array(1) { 11 | [0]=> 12 | string(0) "" 13 | } 14 | -------------------------------------------------------------------------------- /tests/compat/bug68938.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #68938 compat (json_decode() decodes empty string without indicating error) 3 | --FILE-- 4 | getMessage()); 9 | } 10 | ?> 11 | --EXPECT-- 12 | Caught SimdJsonException: Empty: no JSON found 13 | -------------------------------------------------------------------------------- /tests/compat/bug69187.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #69187 compat json_last_error return BC in PHP7 3 | --FILE-- 4 | getCode(), $e->getMessage()); 12 | } 13 | } 14 | var_dump(compat_decode(FALSE)); 15 | var_dump(compat_decode("")); 16 | 17 | var_dump(compat_decode(0)); 18 | var_dump(compat_decode(1)); 19 | var_dump(compat_decode(TRUE)); 20 | 21 | var_dump(compat_decode("\xED\xA0\xB4")); // strangely, 32 bit error is different and "improper structure" instead of "not valid utf-8" 22 | 23 | var_dump(compat_decode("\x00")); 24 | 25 | var_dump(compat_decode("\"\xED\xA0\xB4\"")); 26 | 27 | var_dump(compat_decode("\"\x00\"")); 28 | var_dump(SIMDJSON_ERR_UNESCAPED_CHARS); 29 | ?> 30 | --EXPECTF-- 31 | string(43) "SimdJsonException: 12: Empty: no JSON found" 32 | string(43) "SimdJsonException: 12: Empty: no JSON found" 33 | int(0) 34 | int(1) 35 | int(1) 36 | string(%d) "SimdJsonException: %d: %s 37 | string(124) "SimdJsonException: 3: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc." 38 | string(51) "SimdJsonException: 10: The input is not valid UTF-8" 39 | string(101) "SimdJsonException: 13: Within strings, some characters must be escaped, we found unescaped characters" 40 | int(13) -------------------------------------------------------------------------------- /tests/compat/fail001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | JSON compat (http://www.crockford.com/JSON/JSON_checker/test/fail*.json) 3 | --FILE-- 4 | getMessage()); 40 | } 41 | echo "AS ARRAY\n"; 42 | try { 43 | var_dump(simdjson_decode($test, true)); 44 | } catch (SimdJsonException $e) { 45 | printf("Caught %s: %s\n", get_class($e), $e->getMessage()); 46 | } 47 | } 48 | 49 | ?> 50 | --EXPECT-- 51 | Testing: "A JSON payload should be an object or array, not a string." 52 | AS OBJECT 53 | string(58) "A JSON payload should be an object or array, not a string." 54 | AS ARRAY 55 | string(58) "A JSON payload should be an object or array, not a string." 56 | Testing: ["Unclosed array" 57 | AS OBJECT 58 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 59 | AS ARRAY 60 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 61 | Testing: {unquoted_key: "keys must be quoted} 62 | AS OBJECT 63 | Caught SimdJsonException: A string is opened, but never closed. 64 | AS ARRAY 65 | Caught SimdJsonException: A string is opened, but never closed. 66 | Testing: ["extra comma",] 67 | AS OBJECT 68 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 69 | AS ARRAY 70 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 71 | Testing: ["double extra comma",,] 72 | AS OBJECT 73 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 74 | AS ARRAY 75 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 76 | Testing: [ , "<-- missing value"] 77 | AS OBJECT 78 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 79 | AS ARRAY 80 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 81 | Testing: ["Comma after the close"], 82 | AS OBJECT 83 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 84 | AS ARRAY 85 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 86 | Testing: ["Extra close"]] 87 | AS OBJECT 88 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 89 | AS ARRAY 90 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 91 | Testing: {"Extra comma": true,} 92 | AS OBJECT 93 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 94 | AS ARRAY 95 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 96 | Testing: {"Extra value after close": true} "misplaced quoted value" 97 | AS OBJECT 98 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 99 | AS ARRAY 100 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 101 | Testing: {"Illegal expression": 1 + 2} 102 | AS OBJECT 103 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 104 | AS ARRAY 105 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 106 | Testing: {"Illegal invocation": alert()} 107 | AS OBJECT 108 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 109 | AS ARRAY 110 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 111 | Testing: {"Numbers cannot have leading zeroes": 013} 112 | AS OBJECT 113 | Caught SimdJsonException: Problem while parsing a number 114 | AS ARRAY 115 | Caught SimdJsonException: Problem while parsing a number 116 | Testing: {"Numbers cannot be hex": 0x14} 117 | AS OBJECT 118 | Caught SimdJsonException: Problem while parsing a number 119 | AS ARRAY 120 | Caught SimdJsonException: Problem while parsing a number 121 | Testing: ["Illegal backslash escape: \x15"] 122 | AS OBJECT 123 | Caught SimdJsonException: Problem while parsing a string 124 | AS ARRAY 125 | Caught SimdJsonException: Problem while parsing a string 126 | Testing: ["Illegal backslash escape: \'"] 127 | AS OBJECT 128 | Caught SimdJsonException: Problem while parsing a string 129 | AS ARRAY 130 | Caught SimdJsonException: Problem while parsing a string 131 | Testing: ["Illegal backslash escape: \017"] 132 | AS OBJECT 133 | Caught SimdJsonException: Problem while parsing a string 134 | AS ARRAY 135 | Caught SimdJsonException: Problem while parsing a string 136 | Testing: [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] 137 | AS OBJECT 138 | Caught SimdJsonException: The JSON document was too deep (too many nested objects and arrays) 139 | AS ARRAY 140 | Caught SimdJsonException: The JSON document was too deep (too many nested objects and arrays) 141 | Testing: {"Missing colon" null} 142 | AS OBJECT 143 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 144 | AS ARRAY 145 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 146 | Testing: {"Double colon":: null} 147 | AS OBJECT 148 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 149 | AS ARRAY 150 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 151 | Testing: {"Comma instead of colon", null} 152 | AS OBJECT 153 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 154 | AS ARRAY 155 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 156 | Testing: ["Colon instead of comma": false] 157 | AS OBJECT 158 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 159 | AS ARRAY 160 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 161 | Testing: ["Bad value", truth] 162 | AS OBJECT 163 | Caught SimdJsonException: Problem while parsing an atom starting with the letter 't' 164 | AS ARRAY 165 | Caught SimdJsonException: Problem while parsing an atom starting with the letter 't' 166 | Testing: ['single quote'] 167 | AS OBJECT 168 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 169 | AS ARRAY 170 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. -------------------------------------------------------------------------------- /tests/compat/json_decode_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test simdjson_decode() function compat : basic functionality 3 | --FILE-- 4 | 40 | --EXPECTF-- 41 | *** Testing simdjson_decode() : basic functionality *** 42 | -- Iteration 1 -- 43 | int(0) 44 | int(0) 45 | -- Iteration 2 -- 46 | int(123) 47 | int(123) 48 | -- Iteration 3 -- 49 | int(-123) 50 | int(-123) 51 | -- Iteration 4 -- 52 | int(2147483647) 53 | int(2147483647) 54 | -- Iteration 5 -- 55 | int(-2147483648) 56 | int(-2147483648) 57 | -- Iteration 6 -- 58 | float(123.456) 59 | float(123.456) 60 | -- Iteration 7 -- 61 | int(1230) 62 | int(1230) 63 | -- Iteration 8 -- 64 | int(-1230) 65 | int(-1230) 66 | -- Iteration 9 -- 67 | bool(true) 68 | bool(true) 69 | -- Iteration 10 -- 70 | bool(false) 71 | bool(false) 72 | -- Iteration 11 -- 73 | NULL 74 | NULL 75 | -- Iteration 12 -- 76 | string(3) "abc" 77 | string(3) "abc" 78 | -- Iteration 13 -- 79 | string(13) "Hello World 80 | " 81 | string(13) "Hello World 82 | " 83 | -- Iteration 14 -- 84 | array(0) { 85 | } 86 | array(0) { 87 | } 88 | -- Iteration 15 -- 89 | array(5) { 90 | [0]=> 91 | int(1) 92 | [1]=> 93 | int(2) 94 | [2]=> 95 | int(3) 96 | [3]=> 97 | int(4) 98 | [4]=> 99 | int(5) 100 | } 101 | array(5) { 102 | [0]=> 103 | int(1) 104 | [1]=> 105 | int(2) 106 | [2]=> 107 | int(3) 108 | [3]=> 109 | int(4) 110 | [4]=> 111 | int(5) 112 | } 113 | -- Iteration 16 -- 114 | object(stdClass)#%d (5) { 115 | ["myInt"]=> 116 | int(99) 117 | ["myFloat"]=> 118 | float(123.45) 119 | ["myNull"]=> 120 | NULL 121 | ["myBool"]=> 122 | bool(true) 123 | ["myString"]=> 124 | string(11) "Hello World" 125 | } 126 | array(5) { 127 | ["myInt"]=> 128 | int(99) 129 | ["myFloat"]=> 130 | float(123.45) 131 | ["myNull"]=> 132 | NULL 133 | ["myBool"]=> 134 | bool(true) 135 | ["myString"]=> 136 | string(11) "Hello World" 137 | } 138 | -- Iteration 17 -- 139 | object(stdClass)#%d (6) { 140 | ["Jan"]=> 141 | int(31) 142 | ["Feb"]=> 143 | int(29) 144 | ["Mar"]=> 145 | int(31) 146 | ["April"]=> 147 | int(30) 148 | ["May"]=> 149 | int(31) 150 | ["June"]=> 151 | int(30) 152 | } 153 | array(6) { 154 | ["Jan"]=> 155 | int(31) 156 | ["Feb"]=> 157 | int(29) 158 | ["Mar"]=> 159 | int(31) 160 | ["April"]=> 161 | int(30) 162 | ["May"]=> 163 | int(31) 164 | ["June"]=> 165 | int(30) 166 | } 167 | -- Iteration 18 -- 168 | string(0) "" 169 | string(0) "" 170 | -- Iteration 19 -- 171 | object(stdClass)#%d (0) { 172 | } 173 | array(0) { 174 | } 175 | -------------------------------------------------------------------------------- /tests/compat/json_decode_invalid_utf8.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode() invalid UTF8 3 | --FILE-- 4 | getMessage()); 11 | } 12 | } 13 | simdjson_decode_invalid_utf8("\"a\xb0b\""); 14 | simdjson_decode_invalid_utf8("\"a\xd0\xf2b\""); 15 | simdjson_decode_invalid_utf8("\"\x61\xf0\x80\x80\x41\""); 16 | simdjson_decode_invalid_utf8("[\"\xc1\xc1\",\"a\"]"); 17 | echo "Done\n"; 18 | ?> 19 | --EXPECT-- 20 | Caught SimdJsonException: The input is not valid UTF-8 21 | Caught SimdJsonException: The input is not valid UTF-8 22 | Caught SimdJsonException: The input is not valid UTF-8 23 | Caught SimdJsonException: The input is not valid UTF-8 24 | Done -------------------------------------------------------------------------------- /tests/compat/pass002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | JSON (http://www.crockford.com/JSON/JSON_checker/test/pass2.json) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 32 | --EXPECT-- 33 | Testing: [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] 34 | DECODE: AS OBJECT 35 | array(1) { 36 | [0]=> 37 | array(1) { 38 | [0]=> 39 | array(1) { 40 | [0]=> 41 | array(1) { 42 | [0]=> 43 | array(1) { 44 | [0]=> 45 | array(1) { 46 | [0]=> 47 | array(1) { 48 | [0]=> 49 | array(1) { 50 | [0]=> 51 | array(1) { 52 | [0]=> 53 | array(1) { 54 | [0]=> 55 | array(1) { 56 | [0]=> 57 | array(1) { 58 | [0]=> 59 | array(1) { 60 | [0]=> 61 | array(1) { 62 | [0]=> 63 | array(1) { 64 | [0]=> 65 | array(1) { 66 | [0]=> 67 | array(1) { 68 | [0]=> 69 | array(1) { 70 | [0]=> 71 | array(1) { 72 | [0]=> 73 | string(12) "Not too deep" 74 | } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | } 81 | } 82 | } 83 | } 84 | } 85 | } 86 | } 87 | } 88 | } 89 | } 90 | } 91 | } 92 | } 93 | DECODE: AS ARRAY 94 | array(1) { 95 | [0]=> 96 | array(1) { 97 | [0]=> 98 | array(1) { 99 | [0]=> 100 | array(1) { 101 | [0]=> 102 | array(1) { 103 | [0]=> 104 | array(1) { 105 | [0]=> 106 | array(1) { 107 | [0]=> 108 | array(1) { 109 | [0]=> 110 | array(1) { 111 | [0]=> 112 | array(1) { 113 | [0]=> 114 | array(1) { 115 | [0]=> 116 | array(1) { 117 | [0]=> 118 | array(1) { 119 | [0]=> 120 | array(1) { 121 | [0]=> 122 | array(1) { 123 | [0]=> 124 | array(1) { 125 | [0]=> 126 | array(1) { 127 | [0]=> 128 | array(1) { 129 | [0]=> 130 | array(1) { 131 | [0]=> 132 | string(12) "Not too deep" 133 | } 134 | } 135 | } 136 | } 137 | } 138 | } 139 | } 140 | } 141 | } 142 | } 143 | } 144 | } 145 | } 146 | } 147 | } 148 | } 149 | } 150 | } 151 | } 152 | ENCODE: FROM OBJECT 153 | [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] 154 | ENCODE: FROM ARRAY 155 | [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] 156 | DECODE AGAIN: AS OBJECT 157 | array(1) { 158 | [0]=> 159 | array(1) { 160 | [0]=> 161 | array(1) { 162 | [0]=> 163 | array(1) { 164 | [0]=> 165 | array(1) { 166 | [0]=> 167 | array(1) { 168 | [0]=> 169 | array(1) { 170 | [0]=> 171 | array(1) { 172 | [0]=> 173 | array(1) { 174 | [0]=> 175 | array(1) { 176 | [0]=> 177 | array(1) { 178 | [0]=> 179 | array(1) { 180 | [0]=> 181 | array(1) { 182 | [0]=> 183 | array(1) { 184 | [0]=> 185 | array(1) { 186 | [0]=> 187 | array(1) { 188 | [0]=> 189 | array(1) { 190 | [0]=> 191 | array(1) { 192 | [0]=> 193 | array(1) { 194 | [0]=> 195 | string(12) "Not too deep" 196 | } 197 | } 198 | } 199 | } 200 | } 201 | } 202 | } 203 | } 204 | } 205 | } 206 | } 207 | } 208 | } 209 | } 210 | } 211 | } 212 | } 213 | } 214 | } 215 | DECODE AGAIN: AS ARRAY 216 | array(1) { 217 | [0]=> 218 | array(1) { 219 | [0]=> 220 | array(1) { 221 | [0]=> 222 | array(1) { 223 | [0]=> 224 | array(1) { 225 | [0]=> 226 | array(1) { 227 | [0]=> 228 | array(1) { 229 | [0]=> 230 | array(1) { 231 | [0]=> 232 | array(1) { 233 | [0]=> 234 | array(1) { 235 | [0]=> 236 | array(1) { 237 | [0]=> 238 | array(1) { 239 | [0]=> 240 | array(1) { 241 | [0]=> 242 | array(1) { 243 | [0]=> 244 | array(1) { 245 | [0]=> 246 | array(1) { 247 | [0]=> 248 | array(1) { 249 | [0]=> 250 | array(1) { 251 | [0]=> 252 | array(1) { 253 | [0]=> 254 | string(12) "Not too deep" 255 | } 256 | } 257 | } 258 | } 259 | } 260 | } 261 | } 262 | } 263 | } 264 | } 265 | } 266 | } 267 | } 268 | } 269 | } 270 | } 271 | } 272 | } 273 | } 274 | -------------------------------------------------------------------------------- /tests/compat/pass003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | JSON (http://www.crockford.com/JSON/JSON_checker/test/pass3.json) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 40 | --EXPECTF-- 41 | Testing: 42 | { 43 | "JSON Test Pattern pass3": { 44 | "The outermost value": "must be an object or array.", 45 | "In this test": "It is an object." 46 | } 47 | } 48 | 49 | DECODE: AS OBJECT 50 | object(stdClass)#%d (1) { 51 | ["JSON Test Pattern pass3"]=> 52 | object(stdClass)#%d (2) { 53 | ["The outermost value"]=> 54 | string(27) "must be an object or array." 55 | ["In this test"]=> 56 | string(16) "It is an object." 57 | } 58 | } 59 | DECODE: AS ARRAY 60 | array(1) { 61 | ["JSON Test Pattern pass3"]=> 62 | array(2) { 63 | ["The outermost value"]=> 64 | string(27) "must be an object or array." 65 | ["In this test"]=> 66 | string(16) "It is an object." 67 | } 68 | } 69 | ENCODE: FROM OBJECT 70 | {"JSON Test Pattern pass3":{"The outermost value":"must be an object or array.","In this test":"It is an object."}} 71 | ENCODE: FROM ARRAY 72 | {"JSON Test Pattern pass3":{"The outermost value":"must be an object or array.","In this test":"It is an object."}} 73 | DECODE AGAIN: AS OBJECT 74 | object(stdClass)#%d (1) { 75 | ["JSON Test Pattern pass3"]=> 76 | object(stdClass)#%d (2) { 77 | ["The outermost value"]=> 78 | string(27) "must be an object or array." 79 | ["In this test"]=> 80 | string(16) "It is an object." 81 | } 82 | } 83 | DECODE AGAIN: AS ARRAY 84 | array(1) { 85 | ["JSON Test Pattern pass3"]=> 86 | array(2) { 87 | ["The outermost value"]=> 88 | string(27) "must be an object or array." 89 | ["In this test"]=> 90 | string(16) "It is an object." 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /tests/decode_args.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode args test 3 | --FILE-- 4 | 9 | --EXPECTF-- 10 | Function [ function simdjson_decode ] { 11 | 12 | - Parameters [3] { 13 | Parameter #0 [ string $json ] 14 | Parameter #1 [ bool%S $assoc%S ] 15 | Parameter #2 [ int%S $depth%S ] 16 | } 17 | } -------------------------------------------------------------------------------- /tests/decode_exception.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode throws exception if json is invalid 3 | --FILE-- 4 | getMessage()); 11 | } 12 | 13 | ?> 14 | --EXPECTF-- 15 | string(102) "The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc." -------------------------------------------------------------------------------- /tests/decode_integer_overflow.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode now allows integer/double syntax out of signed/unsigned 64-bit range and double range, matching json_decode() 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | ; in php 8.0 var_dump started using serialize_precision instead of precision 7 | serialize_precision=20 8 | precision=20 9 | --FILE-- 10 | - The specification allows implementations to set limits on the range and precision of numbers accepted. We support 64-bit floating-point numbers as well as integer values. 13 | // > - We parse integers and floating-point numbers as separate types which allows us to support all signed (two's complement) 64-bit integers, like a Java `long` or a C/C++ `long long` and all 64-bit unsigned integers. When we cannot represent exactly an integer as a signed or unsigned 64-bit value, we reject the JSON document. 14 | // > - We support the full range of 64-bit floating-point numbers (binary64). The values range from `std::numeric_limits::lowest()` to `std::numeric_limits::max()`, so from -1.7976e308 all the way to 1.7975e308. Extreme values (less or equal to -1e308, greater or equal to 1e308) are rejected: we refuse to parse the input document. Numbers are parsed with a perfect accuracy (ULP 0): the nearest floating-point value is chosen, rounding to even when needed. If you serialized your floating-point numbers with 17 significant digits in a standard compliant manner, the simdjson library is guaranteed to recover the same numbers, exactly. 15 | function dump_result(string $x) { 16 | echo "Testing " . var_export($x, true) . "\n"; 17 | try { 18 | var_dump(simdjson_decode($x)); 19 | } catch (Exception $e) { 20 | printf("Caught %s: %s\n", get_class($e), $e->getMessage()); 21 | } 22 | } 23 | dump_result('18446744073709551615'); 24 | dump_result('18446744073709551615.0'); 25 | dump_result('18446744073709551615E0'); 26 | dump_result('18446744073709551616'); // simdjson_decode throws but json_decode doesn't. 27 | dump_result('18446744073709551616.0'); 28 | dump_result('-9223372036854775808'); 29 | dump_result('-9223372036854775809'); 30 | dump_result('-9223372036854775809.0'); 31 | dump_result('4000000000000000000000000000000000000000000000000000000'); 32 | dump_result('4000000000000000000000000000000000000000000000000000000.1'); 33 | dump_result('4000000000000000000000000000000000000000000000000000000E1'); 34 | dump_result('4' . str_repeat('0', 305)); 35 | dump_result('4' . str_repeat('0', 309)); 36 | dump_result('1e307'); 37 | dump_result('1e309'); 38 | dump_result('1e309'); 39 | dump_result('1e999999999999'); 40 | dump_result('-1e307'); 41 | dump_result('-1e309'); 42 | dump_result('-1e999999999999'); 43 | dump_result('1e-307'); 44 | dump_result('1e-999'); 45 | dump_result('1e999999'); 46 | dump_result('1e-999999'); 47 | dump_result('0e-999'); 48 | dump_result('0.0'); 49 | dump_result('-1e-307'); 50 | dump_result('-1e-999'); // Tests of https://en.wikipedia.org/wiki/Signed_zero 51 | dump_result('-0e-999'); 52 | dump_result('-0.0'); 53 | ?> 54 | --EXPECT-- 55 | Testing '18446744073709551615' 56 | float(18446744073709551616) 57 | Testing '18446744073709551615.0' 58 | float(18446744073709551616) 59 | Testing '18446744073709551615E0' 60 | float(18446744073709551616) 61 | Testing '18446744073709551616' 62 | float(18446744073709551616) 63 | Testing '18446744073709551616.0' 64 | float(18446744073709551616) 65 | Testing '-9223372036854775808' 66 | int(-9223372036854775808) 67 | Testing '-9223372036854775809' 68 | float(-9223372036854775808) 69 | Testing '-9223372036854775809.0' 70 | float(-9223372036854775808) 71 | Testing '4000000000000000000000000000000000000000000000000000000' 72 | float(4.0000000000000003132E+54) 73 | Testing '4000000000000000000000000000000000000000000000000000000.1' 74 | float(4.0000000000000003132E+54) 75 | Testing '4000000000000000000000000000000000000000000000000000000E1' 76 | float(4.0000000000000000409E+55) 77 | Testing '400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' 78 | float(3.999999999999999757E+305) 79 | Testing '4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' 80 | float(INF) 81 | Testing '1e307' 82 | float(9.9999999999999998603E+306) 83 | Testing '1e309' 84 | float(INF) 85 | Testing '1e309' 86 | float(INF) 87 | Testing '1e999999999999' 88 | float(INF) 89 | Testing '-1e307' 90 | float(-9.9999999999999998603E+306) 91 | Testing '-1e309' 92 | float(-INF) 93 | Testing '-1e999999999999' 94 | float(-INF) 95 | Testing '1e-307' 96 | float(9.9999999999999990933E-308) 97 | Testing '1e-999' 98 | float(0) 99 | Testing '1e999999' 100 | float(INF) 101 | Testing '1e-999999' 102 | float(0) 103 | Testing '0e-999' 104 | float(0) 105 | Testing '0.0' 106 | float(0) 107 | Testing '-1e-307' 108 | float(-9.9999999999999990933E-308) 109 | Testing '-1e-999' 110 | float(-0) 111 | Testing '-0e-999' 112 | float(-0) 113 | Testing '-0.0' 114 | float(-0) -------------------------------------------------------------------------------- /tests/decode_invalid_property.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode throws exception if json object has invalid property 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()); 24 | } 25 | 26 | // allowed for arrays 27 | dump(simdjson_decode($jsonRepeatedInvalid, true)); 28 | 29 | try { 30 | simdjson_decode($jsonRepeatedInvalid); 31 | } catch (\RuntimeException $e) { 32 | var_dump($e->getMessage()); 33 | } 34 | // The empty key is allowed. 35 | var_dump(simdjson_decode($jsonWithEmptyKey)); 36 | var_dump(simdjson_decode($jsonWithEmptyKey, true)); 37 | 38 | ?> 39 | --EXPECT-- 40 | array(2) { 41 | ["key"]=> 42 | array(1) { 43 | [0]=> 44 | int(1) 45 | } 46 | ["\000*\000protected"]=> 47 | string(4) "test" 48 | } 49 | string(21) "Invalid property name" 50 | array(2) { 51 | ["key"]=> 52 | array(1) { 53 | ["\000*\000protected"]=> 54 | string(4) "test" 55 | } 56 | ["\000*\000protected2"]=> 57 | string(4) "test" 58 | } 59 | string(21) "Invalid property name" 60 | object(stdClass)#1 (1) { 61 | [""]=> 62 | bool(true) 63 | } 64 | array(1) { 65 | [""]=> 66 | bool(true) 67 | } -------------------------------------------------------------------------------- /tests/decode_max_depth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode reject max depth 3 | --FILE-- 4 | > 1, PHP_INT_MAX] as $depth) { 11 | dump(function () use ($depth) { return simdjson_decode('[]', true, $depth); }); 12 | dump(function () use ($depth) { return simdjson_key_count('{"a":"b"}', 'a', $depth); }); 13 | dump(function () use ($depth) { return simdjson_key_value('{"a":{}}', 'a', true, $depth); }); 14 | dump(function () use ($depth) { return simdjson_key_exists('{"a":{}}', 'a', $depth); }); 15 | dump(function () use ($depth) { return simdjson_is_valid('{}', $depth); }); 16 | } 17 | ?> 18 | --EXPECTF-- 19 | Caught SimdJsonValueError: simdjson_decode(): Argument #2 ($depth) must be greater than zero 20 | Caught SimdJsonValueError: simdjson_key_count(): Argument #4 ($depth) must be greater than zero 21 | Caught SimdJsonValueError: simdjson_key_value(): Argument #4 ($depth) must be greater than zero 22 | Caught SimdJsonValueError: simdjson_key_exists(): Argument #3 ($depth) must be greater than zero 23 | Caught SimdJsonValueError: simdjson_is_valid(): Argument #2 ($depth) must be greater than zero 24 | Caught SimdJsonValueError: simdjson_decode(): Argument #2 ($depth) must be greater than zero 25 | Caught SimdJsonValueError: simdjson_key_count(): Argument #4 ($depth) must be greater than zero 26 | Caught SimdJsonValueError: simdjson_key_value(): Argument #4 ($depth) must be greater than zero 27 | Caught SimdJsonValueError: simdjson_key_exists(): Argument #3 ($depth) must be greater than zero 28 | Caught SimdJsonValueError: simdjson_is_valid(): Argument #2 ($depth) must be greater than zero 29 | array(0) { 30 | } 31 | int(0) 32 | array(0) { 33 | } 34 | bool(true) 35 | bool(true) 36 | Caught SimdJsonValueError: simdjson_decode(): Argument #2 ($depth) exceeds maximum allowed value of %d 37 | Caught SimdJsonValueError: simdjson_key_count(): Argument #4 ($depth) exceeds maximum allowed value of %d 38 | Caught SimdJsonValueError: simdjson_key_value(): Argument #4 ($depth) exceeds maximum allowed value of %d 39 | Caught SimdJsonValueError: simdjson_key_exists(): Argument #3 ($depth) exceeds maximum allowed value of %d 40 | Caught SimdJsonValueError: simdjson_is_valid(): Argument #2 ($depth) exceeds maximum allowed value of %d 41 | Caught SimdJsonValueError: simdjson_decode(): Argument #2 ($depth) exceeds maximum allowed value of %d 42 | Caught SimdJsonValueError: simdjson_key_count(): Argument #4 ($depth) exceeds maximum allowed value of %d 43 | Caught SimdJsonValueError: simdjson_key_value(): Argument #4 ($depth) exceeds maximum allowed value of %d 44 | Caught SimdJsonValueError: simdjson_key_exists(): Argument #3 ($depth) exceeds maximum allowed value of %d 45 | Caught SimdJsonValueError: simdjson_is_valid(): Argument #2 ($depth) exceeds maximum allowed value of %d 46 | -------------------------------------------------------------------------------- /tests/decode_max_depth_memory_reduction.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode uses smaller depth than max_depth when safe to do so 3 | --FILE-- 4 | getMessage()); 22 | } 23 | } 24 | ?> 25 | --EXPECT-- 26 | Test depth=1024: 27 | array(0) { 28 | } 29 | int(0) 30 | Caught SimdJsonException: The JSON document was too deep (too many nested objects and arrays) 31 | Test depth=134217728: 32 | array(0) { 33 | } 34 | int(0) 35 | Caught SimdJsonException: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. 36 | -------------------------------------------------------------------------------- /tests/decode_repeat.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode repeated keys use the last value 3 | --FILE-- 4 | 13 | --EXPECT-- 14 | object(stdClass)#1 (3) { 15 | ["a"]=> 16 | string(1) "c" 17 | ["0"]=> 18 | array(1) { 19 | [0]=> 20 | int(2) 21 | } 22 | ["foo"]=> 23 | string(3) "baz" 24 | } 25 | array(3) { 26 | ["a"]=> 27 | string(1) "c" 28 | [0]=> 29 | array(1) { 30 | [0]=> 31 | int(2) 32 | } 33 | ["foo"]=> 34 | string(3) "baz" 35 | } 36 | -------------------------------------------------------------------------------- /tests/decode_result.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode test 3 | --FILE-- 4 | 13 | --EXPECTF-- 14 | object(stdClass)#1 (7) { 15 | ["result"]=> 16 | array(2) { 17 | [0]=> 18 | object(stdClass)#2 (4) { 19 | ["_key"]=> 20 | string(5) "70614" 21 | ["_id"]=> 22 | string(14) "products/70614" 23 | ["_rev"]=> 24 | string(11) "_al3hU1K---" 25 | ["Hello3"]=> 26 | string(6) "World3" 27 | } 28 | [1]=> 29 | object(stdClass)#3 (4) { 30 | ["_key"]=> 31 | string(5) "70616" 32 | ["_id"]=> 33 | string(14) "products/70616" 34 | ["_rev"]=> 35 | string(11) "_al3hU1K--A" 36 | ["Hello4"]=> 37 | string(6) "World4" 38 | } 39 | } 40 | ["hasMore"]=> 41 | bool(false) 42 | ["count"]=> 43 | int(2) 44 | ["cached"]=> 45 | bool(false) 46 | ["extra"]=> 47 | object(stdClass)#4 (2) { 48 | ["stats"]=> 49 | object(stdClass)#5 (8) { 50 | ["writesExecuted"]=> 51 | int(0) 52 | ["writesIgnored"]=> 53 | int(0) 54 | ["scannedFull"]=> 55 | int(4) 56 | ["scannedIndex"]=> 57 | int(0) 58 | ["filtered"]=> 59 | int(0) 60 | ["httpRequests"]=> 61 | int(0) 62 | ["executionTime"]=> 63 | float(0.0001473426818847) 64 | ["peakMemoryUsage"]=> 65 | int(2558) 66 | } 67 | ["warnings"]=> 68 | array(0) { 69 | } 70 | } 71 | ["error"]=> 72 | bool(false) 73 | ["code"]=> 74 | int(201) 75 | } 76 | array(7) { 77 | ["result"]=> 78 | array(2) { 79 | [0]=> 80 | array(4) { 81 | ["_key"]=> 82 | string(5) "70614" 83 | ["_id"]=> 84 | string(14) "products/70614" 85 | ["_rev"]=> 86 | string(11) "_al3hU1K---" 87 | ["Hello3"]=> 88 | string(6) "World3" 89 | } 90 | [1]=> 91 | array(4) { 92 | ["_key"]=> 93 | string(5) "70616" 94 | ["_id"]=> 95 | string(14) "products/70616" 96 | ["_rev"]=> 97 | string(11) "_al3hU1K--A" 98 | ["Hello4"]=> 99 | string(6) "World4" 100 | } 101 | } 102 | ["hasMore"]=> 103 | bool(false) 104 | ["count"]=> 105 | int(2) 106 | ["cached"]=> 107 | bool(false) 108 | ["extra"]=> 109 | array(2) { 110 | ["stats"]=> 111 | array(8) { 112 | ["writesExecuted"]=> 113 | int(0) 114 | ["writesIgnored"]=> 115 | int(0) 116 | ["scannedFull"]=> 117 | int(4) 118 | ["scannedIndex"]=> 119 | int(0) 120 | ["filtered"]=> 121 | int(0) 122 | ["httpRequests"]=> 123 | int(0) 124 | ["executionTime"]=> 125 | float(0.0001473426818847) 126 | ["peakMemoryUsage"]=> 127 | int(2558) 128 | } 129 | ["warnings"]=> 130 | array(0) { 131 | } 132 | } 133 | ["error"]=> 134 | bool(false) 135 | ["code"]=> 136 | int(201) 137 | } -------------------------------------------------------------------------------- /tests/decode_strict_types.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode uses strict types 3 | --FILE-- 4 | getMessage()); 11 | } 12 | try { 13 | var_dump(simdjson_key_exists('{}', null)); 14 | } catch (Error $e) { 15 | printf("Caught %s: %s\n", get_class($e), $e->getMessage()); 16 | } 17 | ?> 18 | --EXPECTF-- 19 | Caught TypeError: %Ssimdjson_decode()%S must be of %Stype string, null given 20 | Caught TypeError: %Ssimdjson_key_exists()%S must be of %Stype string, null given 21 | -------------------------------------------------------------------------------- /tests/decode_types.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode test all types 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | array(11) { 20 | [0]=> 21 | object(stdClass)#1 (0) { 22 | } 23 | [1]=> 24 | object(stdClass)#2 (1) { 25 | [""]=> 26 | string(1) "b" 27 | } 28 | [2]=> 29 | string(0) "" 30 | [3]=> 31 | string(1) "x" 32 | [4]=> 33 | int(0) 34 | [5]=> 35 | int(-1) 36 | [6]=> 37 | float(0.5) 38 | [7]=> 39 | NULL 40 | [8]=> 41 | bool(false) 42 | [9]=> 43 | bool(true) 44 | [10]=> 45 | array(0) { 46 | } 47 | } 48 | array(11) { 49 | [0]=> 50 | array(0) { 51 | } 52 | [1]=> 53 | array(1) { 54 | [""]=> 55 | string(1) "b" 56 | } 57 | [2]=> 58 | string(0) "" 59 | [3]=> 60 | string(1) "x" 61 | [4]=> 62 | int(0) 63 | [5]=> 64 | int(-1) 65 | [6]=> 66 | float(0.5) 67 | [7]=> 68 | NULL 69 | [8]=> 70 | bool(false) 71 | [9]=> 72 | bool(true) 73 | [10]=> 74 | array(0) { 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /tests/depth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode depth checked 3 | --INI-- 4 | display_errors=stderr 5 | error_reporting=E_ALL 6 | --FILE-- 7 | getMessage()}\n"; 18 | } 19 | var_dump(simdjson_decode('[1]', true, 2)); 20 | // XXX there's a difference between simdjson_decode and json_decode. 21 | // In json_decode, an array with a scalar has the same depth as an array with no elements. 22 | // In simdjson_decode, an array with a scalar is deeper than an array with no elements. 23 | // For typical use cases, this shouldn't matter. 24 | try { 25 | var_dump(simdjson_decode('[[1]]', true, 2)); 26 | } catch (RuntimeException $e) { 27 | echo "Caught for [[1]]: {$e->getMessage()}\n"; 28 | } 29 | var_dump(simdjson_decode('[[]]', true, 2)); 30 | var_dump(simdjson_decode('[[1]]', true, 3)); 31 | ?> 32 | --EXPECTF-- 33 | int(0) 34 | array(0) { 35 | } 36 | Test '[1]' 37 | Caught for [1]: The JSON document was too deep (too many nested objects and arrays) 38 | array(1) { 39 | [0]=> 40 | int(1) 41 | } 42 | Caught for [[1]]: The JSON document was too deep (too many nested objects and arrays) 43 | array(1) { 44 | [0]=> 45 | array(0) { 46 | } 47 | } 48 | array(1) { 49 | [0]=> 50 | array(1) { 51 | [0]=> 52 | int(1) 53 | } 54 | } -------------------------------------------------------------------------------- /tests/dump.inc: -------------------------------------------------------------------------------- 1 | getMessage()); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/is_valid.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_is_valid test 3 | --FILE-- 4 | 19 | --EXPECTF-- 20 | bool(true) 21 | bool(false) 22 | bool(false) 23 | bool(false) -------------------------------------------------------------------------------- /tests/is_valid_args.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_is_valid args test 3 | --FILE-- 4 | 9 | --EXPECTF-- 10 | Function [ function simdjson_is_valid ] { 11 | 12 | - Parameters [2] { 13 | Parameter #0 [ string $json ] 14 | Parameter #1 [ int%S $depth%S ] 15 | } 16 | - Return [ bool%S ] 17 | } -------------------------------------------------------------------------------- /tests/is_valid_edge_cases.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_is_valid edge cases test 3 | --INI-- 4 | error_reporting=E_ALL 5 | display_errors=stderr 6 | --FILE-- 7 | 20 | --EXPECTF-- 21 | Caught SimdJsonValueError: simdjson_is_valid(): Argument #2 ($depth) must be greater than zero 22 | bool(true) 23 | bool(true) 24 | bool(false) 25 | bool(true) 26 | test deeply nested 27 | bool(false) 28 | bool(false) 29 | bool(true) 30 | -------------------------------------------------------------------------------- /tests/key_count.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_count test 3 | --FILE-- 4 | 13 | --EXPECTF-- 14 | int(2) 15 | int(8) -------------------------------------------------------------------------------- /tests/key_count_args.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_count args test 3 | --FILE-- 4 | 9 | --EXPECTF-- 10 | Function [ function simdjson_key_count ] { 11 | 12 | - Parameters [4] { 13 | Parameter #0 [ string $json ] 14 | Parameter #1 [ string $key ] 15 | Parameter #2 [ int%S $depth%S ] 16 | Parameter #3 [ bool%S $throw_if_uncountable%S ] 17 | } 18 | - Return [ int%S ] 19 | } -------------------------------------------------------------------------------- /tests/key_count_exception.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_count throws exception if key was not found test 3 | --FILE-- 4 | getMessage()); 11 | } 12 | 13 | try { 14 | \simdjson_key_count($json, "unknown"); 15 | } catch (\RuntimeException $e) { 16 | var_dump($e->getMessage()); 17 | } 18 | 19 | ?> 20 | --EXPECT-- 21 | string(67) "The JSON document was too deep (too many nested objects and arrays)" 22 | string(56) "The JSON field referenced does not exist in this object." -------------------------------------------------------------------------------- /tests/key_count_large.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_count large value test 3 | --SKIPIF-- 4 | 9 | --INI-- 10 | memory_limit=2G 11 | --FILE-- 12 | $x], $flags); 27 | unset($x); 28 | var_dump(simdjson_key_count($str, "x")); 29 | } 30 | dump_count([]); 31 | dump_count([1 => '2']); 32 | dump_count(my_array_repeat(1, 0x1000000), JSON_FORCE_OBJECT); 33 | dump_count(my_array_repeat(1, 0x1000000)); 34 | dump_count(my_array_repeat(1, 0x0FFFFFF), JSON_FORCE_OBJECT); 35 | dump_count(my_array_repeat(1, 0x0FFFFFF)); 36 | ?> 37 | --EXPECTF-- 38 | int(0) 39 | int(1) 40 | int(16777216) 41 | int(16777216) 42 | int(16777215) 43 | int(16777215) 44 | -------------------------------------------------------------------------------- /tests/key_exists.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_exists test 3 | --FILE-- 4 | 22 | --EXPECTF-- 23 | bool(true) 24 | bool(true) 25 | bool(false) 26 | bool(false) 27 | bool(false) -------------------------------------------------------------------------------- /tests/key_exists_args.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_exists args test 3 | --FILE-- 4 | 9 | --EXPECTF-- 10 | Function [ function simdjson_key_exists ] { 11 | 12 | - Parameters [3] { 13 | Parameter #0 [ string $json ] 14 | Parameter #1 [ string $key ] 15 | Parameter #2 [ int%S $depth%S ] 16 | } 17 | - Return [ bool%S ] 18 | } -------------------------------------------------------------------------------- /tests/key_value_args.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_value args test 3 | --FILE-- 4 | 9 | --EXPECTF-- 10 | Function [ function simdjson_key_value ] { 11 | 12 | - Parameters [4] { 13 | Parameter #0 [ string $json ] 14 | Parameter #1 [ string $key ] 15 | Parameter #2 [ bool%S $assoc%S ] 16 | Parameter #3 [ int%S $depth%S ] 17 | } 18 | } -------------------------------------------------------------------------------- /tests/key_value_deep_string.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_value with deep string test 3 | --FILE-- 4 | 13 | --EXPECTF-- 14 | string(6) "World3" 15 | string(6) "World3" -------------------------------------------------------------------------------- /tests/key_value_exception.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_value throws exception if key was not found test 3 | --FILE-- 4 | getMessage()); 11 | } 12 | 13 | ?> 14 | --EXPECTF-- 15 | string(56) "The JSON field referenced does not exist in this object." -------------------------------------------------------------------------------- /tests/key_value_int.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_value with int test 3 | --FILE-- 4 | 13 | --EXPECTF-- 14 | int(201) 15 | int(201) 16 | -------------------------------------------------------------------------------- /tests/key_value_result.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_value with deep string test 3 | --FILE-- 4 | 13 | --EXPECTF-- 14 | array(2) { 15 | [0]=> 16 | object(stdClass)#1 (4) { 17 | ["_key"]=> 18 | string(5) "70614" 19 | ["_id"]=> 20 | string(14) "products/70614" 21 | ["_rev"]=> 22 | string(11) "_al3hU1K---" 23 | ["Hello3"]=> 24 | string(6) "World3" 25 | } 26 | [1]=> 27 | object(stdClass)#2 (4) { 28 | ["_key"]=> 29 | string(5) "70616" 30 | ["_id"]=> 31 | string(14) "products/70616" 32 | ["_rev"]=> 33 | string(11) "_al3hU1K--A" 34 | ["Hello4"]=> 35 | string(6) "World4" 36 | } 37 | } 38 | array(2) { 39 | [0]=> 40 | array(4) { 41 | ["_key"]=> 42 | string(5) "70614" 43 | ["_id"]=> 44 | string(14) "products/70614" 45 | ["_rev"]=> 46 | string(11) "_al3hU1K---" 47 | ["Hello3"]=> 48 | string(6) "World3" 49 | } 50 | [1]=> 51 | array(4) { 52 | ["_key"]=> 53 | string(5) "70616" 54 | ["_id"]=> 55 | string(14) "products/70616" 56 | ["_rev"]=> 57 | string(11) "_al3hU1K--A" 58 | ["Hello4"]=> 59 | string(6) "World4" 60 | } 61 | } -------------------------------------------------------------------------------- /tests/key_value_slash.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_key_value with int test 3 | --SKIPIF-- 4 | 30 | --EXPECT-- 31 | Test '/code' 32 | int(123) 33 | int(123) 34 | Test '/' 35 | bool(true) 36 | bool(true) 37 | Test '' 38 | object(stdClass)#2 (4) { 39 | [""]=> 40 | bool(true) 41 | ["code"]=> 42 | int(123) 43 | ["values"]=> 44 | array(1) { 45 | [0]=> 46 | object(stdClass)#3 (0) { 47 | } 48 | } 49 | ["obj"]=> 50 | object(stdClass)#4 (1) { 51 | ["z"]=> 52 | bool(false) 53 | } 54 | } 55 | array(4) { 56 | [""]=> 57 | bool(true) 58 | ["code"]=> 59 | int(123) 60 | ["values"]=> 61 | array(1) { 62 | [0]=> 63 | array(0) { 64 | } 65 | } 66 | ["obj"]=> 67 | array(1) { 68 | ["z"]=> 69 | bool(false) 70 | } 71 | } 72 | Test '/code' 73 | int(123) 74 | int(123) 75 | Test '/code/0' 76 | Caught SimdJsonException: Invalid JSON pointer syntax. 77 | Caught SimdJsonException: Invalid JSON pointer syntax. 78 | Test '/code/x' 79 | Caught SimdJsonException: Invalid JSON pointer syntax. 80 | Caught SimdJsonException: Invalid JSON pointer syntax. 81 | Test '/values' 82 | array(1) { 83 | [0]=> 84 | object(stdClass)#2 (0) { 85 | } 86 | } 87 | array(1) { 88 | [0]=> 89 | array(0) { 90 | } 91 | } 92 | Test '/values/0' 93 | object(stdClass)#2 (0) { 94 | } 95 | array(0) { 96 | } 97 | Test '/values/1' 98 | Caught SimdJsonException: Attempted to access an element of a JSON array that is beyond its length. 99 | Caught SimdJsonException: Attempted to access an element of a JSON array that is beyond its length. 100 | Test '/values/-1' 101 | Caught SimdJsonException: The JSON element does not have the requested type. 102 | Caught SimdJsonException: The JSON element does not have the requested type. 103 | Test '/obj' 104 | object(stdClass)#2 (1) { 105 | ["z"]=> 106 | bool(false) 107 | } 108 | array(1) { 109 | ["z"]=> 110 | bool(false) 111 | } 112 | Test '/obj/z' 113 | bool(false) 114 | bool(false) 115 | -------------------------------------------------------------------------------- /tests/uint64_overflow.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | simdjson_decode uint64_t overflow test 3 | --FILE-- 4 | getMessage()); 14 | } 15 | ?> 16 | --EXPECT-- 17 | 9223372036854775808.0 18 | 18446744073709551616.0 19 | 18446744073709551616.0 20 | --------------------------------------------------------------------------------