xonixx / gron.awk Goto Github PK
View Code? Open in Web Editor NEWGron in Awk
License: MIT License
Gron in Awk
License: MIT License
First of all, thanks for making gron.awk - amazing project :)
Is there an easy way to add support for multiple input files? So that you can do something like:
gron.awk file1.json file2.json file3.json
Not a critical feature, as I can emulate it using xargs, but would be nice to have.
With busybox awk support
Ubuntu 22.04.3 LTS
$ mawk -W version
mawk 1.3.4 20200120
Copyright 2008-2019,2020, Thomas E. Dickey
Copyright 1991-1996,2014, Michael D. Brennan
random-funcs: srandom/random
regex-funcs: internal
compiled limits:
sprintf buffer 8192
maximum-integer 2147483647
goal 'JSONTestSuite_installed' [already satisfied].
goal 'test_suite' ...
FAIL : i_number_double_huge_neg_exp.json
FAIL : i_number_huge_exp.json
FAIL : i_number_neg_int_huge_exp.json
FAIL : i_number_pos_double_huge_exp.json
FAIL : i_number_real_neg_overflow.json
FAIL : i_number_real_pos_overflow.json
FAIL : i_number_real_underflow.json
FAIL : i_number_too_big_neg_int.json
FAIL : i_number_too_big_pos_int.json
FAIL : i_number_very_big_negative_int.json
FAIL : i_object_key_lone_2nd_surrogate.json
FAIL : i_string_1st_surrogate_but_2nd_missing.json
FAIL : i_string_1st_valid_surrogate_2nd_invalid.json
FAIL : i_string_UTF-16LE_with_BOM.json
FAIL : i_string_UTF-8_invalid_sequence.json
FAIL : i_string_UTF8_surrogate_U+D800.json
FAIL : i_string_incomplete_surrogate_and_escape_valid.json
FAIL : i_string_incomplete_surrogate_pair.json
FAIL : i_string_incomplete_surrogates_escape_valid.json
FAIL : i_string_invalid_lonely_surrogate.json
FAIL : i_string_invalid_surrogate.json
FAIL : i_string_invalid_utf-8.json
FAIL : i_string_inverted_surrogates_U+1D11E.json
FAIL : i_string_iso_latin_1.json
FAIL : i_string_lone_second_surrogate.json
FAIL : i_string_lone_utf8_continuation_byte.json
FAIL : i_string_not_in_unicode_range.json
FAIL : i_string_overlong_sequence_2_bytes.json
FAIL : i_string_overlong_sequence_6_bytes.json
FAIL : i_string_overlong_sequence_6_bytes_null.json
FAIL : i_string_truncated-utf-8.json
FAIL : i_string_utf16BE_no_BOM.json
FAIL : i_string_utf16LE_no_BOM.json
FAIL : i_structure_500_nested_arrays.json
FAIL : i_structure_UTF-8_BOM_empty_object.json
SUCCESS : n_array_1_true_without_comma.json
SUCCESS : n_array_a_invalid_utf8.json
SUCCESS : n_array_colon_instead_of_comma.json
SUCCESS : n_array_comma_after_close.json
SUCCESS : n_array_comma_and_number.json
SUCCESS : n_array_double_comma.json
SUCCESS : n_array_double_extra_comma.json
SUCCESS : n_array_extra_close.json
SUCCESS : n_array_extra_comma.json
SUCCESS : n_array_incomplete.json
SUCCESS : n_array_incomplete_invalid_value.json
SUCCESS : n_array_inner_array_no_comma.json
SUCCESS : n_array_invalid_utf8.json
SUCCESS : n_array_items_separated_by_semicolon.json
SUCCESS : n_array_just_comma.json
SUCCESS : n_array_just_minus.json
SUCCESS : n_array_missing_value.json
SUCCESS : n_array_newlines_unclosed.json
SUCCESS : n_array_number_and_comma.json
SUCCESS : n_array_number_and_several_commas.json
SUCCESS : n_array_spaces_vertical_tab_formfeed.json
SUCCESS : n_array_star_inside.json
SUCCESS : n_array_unclosed.json
SUCCESS : n_array_unclosed_trailing_comma.json
SUCCESS : n_array_unclosed_with_new_lines.json
SUCCESS : n_array_unclosed_with_object_inside.json
SUCCESS : n_incomplete_false.json
SUCCESS : n_incomplete_null.json
SUCCESS : n_incomplete_true.json
SUCCESS : n_multidigit_number_then_00.json
SUCCESS : n_number_++.json
SUCCESS : n_number_+1.json
SUCCESS : n_number_+Inf.json
SUCCESS : n_number_-01.json
SUCCESS : n_number_-1.0..json
SUCCESS : n_number_-2..json
SUCCESS : n_number_-NaN.json
SUCCESS : n_number_.-1.json
SUCCESS : n_number_.2e-3.json
SUCCESS : n_number_0.1.2.json
SUCCESS : n_number_0.3e+.json
SUCCESS : n_number_0.3e.json
SUCCESS : n_number_0.e1.json
SUCCESS : n_number_0_capital_E+.json
SUCCESS : n_number_0_capital_E.json
SUCCESS : n_number_0e+.json
SUCCESS : n_number_0e.json
SUCCESS : n_number_1.0e+.json
SUCCESS : n_number_1.0e-.json
SUCCESS : n_number_1.0e.json
SUCCESS : n_number_1_000.json
SUCCESS : n_number_1eE2.json
SUCCESS : n_number_2.e+3.json
SUCCESS : n_number_2.e-3.json
SUCCESS : n_number_2.e3.json
SUCCESS : n_number_9.e+.json
SUCCESS : n_number_Inf.json
SUCCESS : n_number_NaN.json
SUCCESS : n_number_U+FF11_fullwidth_digit_one.json
SUCCESS : n_number_expression.json
SUCCESS : n_number_hex_1_digit.json
SUCCESS : n_number_hex_2_digits.json
SUCCESS : n_number_infinity.json
SUCCESS : n_number_invalid+-.json
SUCCESS : n_number_invalid-negative-real.json
SUCCESS : n_number_invalid-utf-8-in-bigger-int.json
SUCCESS : n_number_invalid-utf-8-in-exponent.json
SUCCESS : n_number_invalid-utf-8-in-int.json
SUCCESS : n_number_minus_infinity.json
SUCCESS : n_number_minus_sign_with_trailing_garbage.json
SUCCESS : n_number_minus_space_1.json
SUCCESS : n_number_neg_int_starting_with_zero.json
SUCCESS : n_number_neg_real_without_int_part.json
SUCCESS : n_number_neg_with_garbage_at_end.json
SUCCESS : n_number_real_garbage_after_e.json
SUCCESS : n_number_real_with_invalid_utf8_after_e.json
SUCCESS : n_number_real_without_fractional_part.json
SUCCESS : n_number_starting_with_dot.json
SUCCESS : n_number_with_alpha.json
SUCCESS : n_number_with_alpha_char.json
SUCCESS : n_number_with_leading_zero.json
SUCCESS : n_object_bad_value.json
SUCCESS : n_object_bracket_key.json
SUCCESS : n_object_comma_instead_of_colon.json
SUCCESS : n_object_double_colon.json
SUCCESS : n_object_emoji.json
SUCCESS : n_object_garbage_at_end.json
SUCCESS : n_object_key_with_single_quotes.json
SUCCESS : n_object_lone_continuation_byte_in_key_and_trailing_comma.json
SUCCESS : n_object_missing_colon.json
SUCCESS : n_object_missing_key.json
SUCCESS : n_object_missing_semicolon.json
SUCCESS : n_object_missing_value.json
SUCCESS : n_object_no-colon.json
SUCCESS : n_object_non_string_key.json
SUCCESS : n_object_non_string_key_but_huge_number_instead.json
SUCCESS : n_object_repeated_null_null.json
SUCCESS : n_object_several_trailing_commas.json
SUCCESS : n_object_single_quote.json
SUCCESS : n_object_trailing_comma.json
SUCCESS : n_object_trailing_comment.json
SUCCESS : n_object_trailing_comment_open.json
SUCCESS : n_object_trailing_comment_slash_open.json
SUCCESS : n_object_trailing_comment_slash_open_incomplete.json
SUCCESS : n_object_two_commas_in_a_row.json
SUCCESS : n_object_unquoted_key.json
SUCCESS : n_object_unterminated-value.json
SUCCESS : n_object_with_single_string.json
SUCCESS : n_object_with_trailing_garbage.json
SUCCESS : n_single_space.json
SUCCESS : n_string_1_surrogate_then_escape.json
SUCCESS : n_string_1_surrogate_then_escape_u.json
SUCCESS : n_string_1_surrogate_then_escape_u1.json
SUCCESS : n_string_1_surrogate_then_escape_u1x.json
SUCCESS : n_string_accentuated_char_no_quotes.json
SUCCESS : n_string_backslash_00.json
SUCCESS : n_string_escape_x.json
SUCCESS : n_string_escaped_backslash_bad.json
SUCCESS : n_string_escaped_ctrl_char_tab.json
SUCCESS : n_string_escaped_emoji.json
SUCCESS : n_string_incomplete_escape.json
SUCCESS : n_string_incomplete_escaped_character.json
SUCCESS : n_string_incomplete_surrogate.json
SUCCESS : n_string_incomplete_surrogate_escape_invalid.json
SUCCESS : n_string_invalid-utf-8-in-escape.json
SUCCESS : n_string_invalid_backslash_esc.json
SUCCESS : n_string_invalid_unicode_escape.json
SUCCESS : n_string_invalid_utf8_after_escape.json
SUCCESS : n_string_leading_uescaped_thinspace.json
SUCCESS : n_string_no_quotes_with_bad_escape.json
SUCCESS : n_string_single_doublequote.json
SUCCESS : n_string_single_quote.json
SUCCESS : n_string_single_string_no_double_quotes.json
SUCCESS : n_string_start_escape_unclosed.json
SUCCESS : n_string_unescaped_ctrl_char.json
SUCCESS : n_string_unescaped_newline.json
SUCCESS : n_string_unescaped_tab.json
SUCCESS : n_string_unicode_CapitalU.json
SUCCESS : n_string_with_trailing_garbage.json
SUCCESS : n_structure_U+2060_word_joined.json
SUCCESS : n_structure_UTF8_BOM_no_data.json
SUCCESS : n_structure_angle_bracket_..json
SUCCESS : n_structure_angle_bracket_null.json
SUCCESS : n_structure_array_trailing_garbage.json
SUCCESS : n_structure_array_with_extra_array_close.json
SUCCESS : n_structure_array_with_unclosed_string.json
SUCCESS : n_structure_ascii-unicode-identifier.json
SUCCESS : n_structure_capitalized_True.json
SUCCESS : n_structure_close_unopened_array.json
SUCCESS : n_structure_comma_instead_of_closing_brace.json
SUCCESS : n_structure_double_array.json
SUCCESS : n_structure_end_array.json
SUCCESS : n_structure_incomplete_UTF8_BOM.json
SUCCESS : n_structure_lone-invalid-utf-8.json
SUCCESS : n_structure_lone-open-bracket.json
SUCCESS : n_structure_no_data.json
SUCCESS : n_structure_null-byte-outside-string.json
SUCCESS : n_structure_number_with_trailing_garbage.json
SUCCESS : n_structure_object_followed_by_closing_object.json
SUCCESS : n_structure_object_unclosed_no_value.json
SUCCESS : n_structure_object_with_comment.json
SUCCESS : n_structure_object_with_trailing_garbage.json
SUCCESS : n_structure_open_array_apostrophe.json
SUCCESS : n_structure_open_array_comma.json
SUCCESS : n_structure_open_array_open_object.json
SUCCESS : n_structure_open_array_open_string.json
SUCCESS : n_structure_open_array_string.json
SUCCESS : n_structure_open_object.json
SUCCESS : n_structure_open_object_close_array.json
SUCCESS : n_structure_open_object_comma.json
SUCCESS : n_structure_open_object_open_array.json
SUCCESS : n_structure_open_object_open_string.json
SUCCESS : n_structure_open_object_string_with_apostrophes.json
SUCCESS : n_structure_open_open.json
SUCCESS : n_structure_single_eacute.json
SUCCESS : n_structure_single_star.json
SUCCESS : n_structure_trailing_#.json
SUCCESS : n_structure_uescaped_LF_before_string.json
SUCCESS : n_structure_unclosed_array.json
SUCCESS : n_structure_unclosed_array_partial_null.json
SUCCESS : n_structure_unclosed_array_unfinished_false.json
SUCCESS : n_structure_unclosed_array_unfinished_true.json
SUCCESS : n_structure_unclosed_object.json
SUCCESS : n_structure_unicode-identifier.json
SUCCESS : n_structure_whitespace_U+2060_word_joiner.json
SUCCESS : n_structure_whitespace_formfeed.json
FAIL : y_array_arraysWithSpaces.json
FAIL : y_array_empty-string.json
FAIL : y_array_empty.json
FAIL : y_array_ending_with_newline.json
FAIL : y_array_false.json
FAIL : y_array_heterogeneous.json
FAIL : y_array_null.json
FAIL : y_array_with_1_and_newline.json
FAIL : y_array_with_leading_space.json
FAIL : y_array_with_several_null.json
FAIL : y_array_with_trailing_space.json
FAIL : y_number.json
FAIL : y_number_0e+1.json
FAIL : y_number_0e1.json
FAIL : y_number_after_space.json
FAIL : y_number_double_close_to_zero.json
FAIL : y_number_int_with_exp.json
FAIL : y_number_minus_zero.json
FAIL : y_number_negative_int.json
FAIL : y_number_negative_one.json
FAIL : y_number_negative_zero.json
FAIL : y_number_real_capital_e.json
FAIL : y_number_real_capital_e_neg_exp.json
FAIL : y_number_real_capital_e_pos_exp.json
FAIL : y_number_real_exponent.json
FAIL : y_number_real_fraction_exponent.json
FAIL : y_number_real_neg_exp.json
FAIL : y_number_real_pos_exponent.json
FAIL : y_number_simple_int.json
FAIL : y_number_simple_real.json
FAIL : y_object.json
FAIL : y_object_basic.json
FAIL : y_object_duplicated_key.json
FAIL : y_object_duplicated_key_and_value.json
FAIL : y_object_empty.json
FAIL : y_object_empty_key.json
FAIL : y_object_escaped_null_in_key.json
FAIL : y_object_extreme_numbers.json
FAIL : y_object_long_strings.json
FAIL : y_object_simple.json
FAIL : y_object_string_unicode.json
FAIL : y_object_with_newlines.json
FAIL : y_string_1_2_3_bytes_UTF-8_sequences.json
FAIL : y_string_accepted_surrogate_pair.json
FAIL : y_string_accepted_surrogate_pairs.json
FAIL : y_string_allowed_escapes.json
FAIL : y_string_backslash_and_u_escaped_zero.json
FAIL : y_string_backslash_doublequotes.json
FAIL : y_string_comments.json
FAIL : y_string_double_escape_a.json
FAIL : y_string_double_escape_n.json
FAIL : y_string_escaped_control_character.json
FAIL : y_string_escaped_noncharacter.json
FAIL : y_string_in_array.json
FAIL : y_string_in_array_with_leading_space.json
FAIL : y_string_last_surrogates_1_and_2.json
FAIL : y_string_nbsp_uescaped.json
FAIL : y_string_nonCharacterInUTF-8_U+10FFFF.json
FAIL : y_string_nonCharacterInUTF-8_U+FFFF.json
FAIL : y_string_null_escape.json
FAIL : y_string_one-byte-utf-8.json
FAIL : y_string_pi.json
FAIL : y_string_reservedCharacterInUTF-8_U+1BFFF.json
FAIL : y_string_simple_ascii.json
FAIL : y_string_space.json
FAIL : y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json
FAIL : y_string_three-byte-utf-8.json
FAIL : y_string_two-byte-utf-8.json
FAIL : y_string_u+2028_line_sep.json
FAIL : y_string_u+2029_par_sep.json
FAIL : y_string_uEscape.json
FAIL : y_string_uescaped_newline.json
FAIL : y_string_unescaped_char_delete.json
FAIL : y_string_unicode.json
FAIL : y_string_unicodeEscapedBackslash.json
FAIL : y_string_unicode_2.json
FAIL : y_string_unicode_U+10FFFE_nonchar.json
FAIL : y_string_unicode_U+1FFFE_nonchar.json
FAIL : y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json
FAIL : y_string_unicode_U+2064_invisible_plus.json
FAIL : y_string_unicode_U+FDD0_nonchar.json
FAIL : y_string_unicode_U+FFFE_nonchar.json
FAIL : y_string_unicode_escaped_double_quote.json
FAIL : y_string_utf8.json
FAIL : y_string_with_del_character.json
FAIL : y_structure_lonely_false.json
FAIL : y_structure_lonely_int.json
FAIL : y_structure_lonely_negative_real.json
FAIL : y_structure_lonely_null.json
FAIL : y_structure_lonely_string.json
FAIL : y_structure_lonely_true.json
FAIL : y_structure_string_empty.json
FAIL : y_structure_trailing_newline.json
FAIL : y_structure_true_in_array.json
FAIL : y_structure_whitespace_array.json
FAIL : number_-9223372036854775808.json
FAIL : number_-9223372036854775809.json
FAIL : number_1.0.json
FAIL : number_1.000000000000000005.json
FAIL : number_1000000000000000.json
FAIL : number_10000000000000000999.json
FAIL : number_1e-999.json
FAIL : number_1e6.json
FAIL : number_9223372036854775807.json
FAIL : number_9223372036854775808.json
FAIL : object_key_nfc_nfd.json
FAIL : object_key_nfd_nfc.json
FAIL : object_same_key_different_values.json
FAIL : object_same_key_same_value.json
FAIL : object_same_key_unclear_values.json
FAIL : string_1_escaped_invalid_codepoint.json
FAIL : string_1_invalid_codepoint.json
FAIL : string_2_escaped_invalid_codepoints.json
FAIL : string_2_invalid_codepoints.json
FAIL : string_3_escaped_invalid_codepoints.json
FAIL : string_3_invalid_codepoints.json
FAIL : string_with_escaped_NULL.json
Successes: 186
Fails: 152
goal 'test_suite' took 0.309 s
total time 0.313 s
Now we parse
json.a.b=1
json.a.c="CCC"
Let's aditionally allow
json.a.b = 1;
json.a.c = "CCC";
goal 'tested_gawk51' ...
goal 'fhtagn_installed' [already satisfied].
goal 'debug' ...
/home/xonix/proj/gron.awk/soft/gawk51: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory
Atm we read the whole JSON into memory, then parse as a whole string.
What if we read one char at a time from input and parse on the fly?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.