Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package guile-json for openSUSE:Factory checked in at 2022-09-25 15:35:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/guile-json (Old) and /work/SRC/openSUSE:Factory/.guile-json.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "guile-json" Sun Sep 25 15:35:18 2022 rev:11 rq:1005718 version:4.7.2 Changes: -------- --- /work/SRC/openSUSE:Factory/guile-json/guile-json.changes 2021-05-13 22:18:54.395511842 +0200 +++ /work/SRC/openSUSE:Factory/.guile-json.new.2275/guile-json.changes 2022-09-25 15:35:40.347676313 +0200 @@ -1,0 +2,10 @@ +Sat Sep 17 07:52:47 UTC 2022 - Jonathan Brielmaier <[email protected]> + +- Update to 4.7.2: + * add support for JSON Text Sequences and Concatenated JSON + * allow returning ordered JSON objects key/value pairs by using + the keyword argument #:ordered + * allow nested records in other records +- remove rpmlintrc as no longer required + +------------------------------------------------------------------- Old: ---- guile-json-4.5.2.tar.gz guile-json-4.5.2.tar.gz.sig guile-json-rpmlintrc New: ---- guile-json-4.7.2.tar.gz guile-json-4.7.2.tar.gz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ guile-json.spec ++++++ --- /var/tmp/diff_new_pack.6Gkvct/_old 2022-09-25 15:35:40.867677566 +0200 +++ /var/tmp/diff_new_pack.6Gkvct/_new 2022-09-25 15:35:40.871677575 +0200 @@ -1,7 +1,7 @@ # # spec file for package guile-json # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: guile-json -Version: 4.5.2 +Version: 4.7.2 Release: 0 Summary: JSON module for Guile License: GPL-3.0-or-later @@ -26,7 +26,6 @@ Source0: http://download.savannah.gnu.org/releases/guile-json/%{name}-%{version}.tar.gz Source1: http://download.savannah.gnu.org/releases/guile-json/%{name}-%{version}.tar.gz.sig Source2: https://savannah.nongnu.org/people/viewgpg.php?user_id=11331#/%{name}.keyring -Source1000: guile-json-rpmlintrc BuildRequires: guile-devel >= 2.0.10 Requires: guile >= 2.0.10 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ guile-json-4.5.2.tar.gz -> guile-json-4.7.2.tar.gz ++++++ ++++ 4109 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/ChangeLog new/guile-json-4.7.2/ChangeLog --- old/guile-json-4.5.2/ChangeLog 2021-02-03 22:14:51.000000000 +0100 +++ new/guile-json-4.7.2/ChangeLog 2022-06-26 10:43:24.000000000 +0200 @@ -1,3 +1,258 @@ +commit fcb13775564d191e1a0f75764f760492219fd615 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Sun Jun 26 01:41:46 2022 -0700 + + record: also fix nested record for vectors + + json/record.scm | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 38d4bf0b10d585401ace263522ed8d67f79f2678 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Sun Jun 26 01:36:12 2022 -0700 + + bump version to 4.7.2 + + NEWS | 7 +++++++ + README.md | 2 +- + configure.ac | 2 +- + 3 files changed, 9 insertions(+), 2 deletions(-) + +commit 8104d5bc234441a3d7c8db263a5d1d0e46d35aa1 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Sun Jun 26 01:26:46 2022 -0700 + + record: don't call scm->record if value is *unspecified* in (define-json-type) + + Given the following example: + + (define-json-type <account> + (id) + (username) + (omitted "omitted" <omitted>) + (boolean)) + + (define-json-type <omitted> + (name)) + + If `omitted` is *unspecified* there's no need to keep going through that field. + + This also rolls back part of commit 029212e. + + Fixes #78 + + json/record.scm | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +commit 81bc5dad9f588fd49816d2fd3983551e56e078ea +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Tue Apr 19 21:38:49 2022 -0700 + + bump version to 4.7.1 + + NEWS | 7 +++++++ + README.md | 10 ++++++---- + configure.ac | 2 +- + 3 files changed, 14 insertions(+), 5 deletions(-) + +commit 029212e0b74c85b940c4b565e36e97ac26741efd +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Mon Apr 18 22:01:40 2022 -0700 + + records: allow optional nested records + + Fixes #78 + + json/record.scm | 12 ++++++------ + tests/test-record.scm | 27 ++++++++++++++++++++++++++- + 2 files changed, 32 insertions(+), 7 deletions(-) + +commit 19410cbf89762c61995e62ed1d229db6ff8881ab +Author: Vagrant Cascadian <[email protected]> +Date: Wed Jan 5 18:51:50 2022 -0800 + + json/record.scm: Fix spelling of "Additionally". + + json/record.scm | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 488b17283723de3429c9e11ad30a21e97c57ecd1 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Wed Jan 5 23:00:05 2022 -0800 + + INSTALL: new version + + INSTALL | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 95514c8ff0c1b50ee1803bc784eb064334f81182 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Sun Jan 2 16:34:50 2022 -0800 + + bump version to 4.7.0 + + NEWS | 7 +++++++ + README.md | 23 ++++++++++++++++------- + configure.ac | 4 ++-- + 3 files changed, 25 insertions(+), 9 deletions(-) + +commit 895802eefb28a162a532eb13da302a7fcb07a25a +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Sun Jan 2 16:33:57 2022 -0800 + + parser: allow JSON object ordering + + Closes #77 + + json/parser.scm | 71 +++++++++++++++++++++++++++------------------------ + tests/test-parser.scm | 6 ++++- + 2 files changed, 43 insertions(+), 34 deletions(-) + +commit 7b42db265d66af52ed097ab672c86ff2c728938d +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Tue Dec 28 07:49:27 2021 -0800 + + bump version to 4.6.0 + + NEWS | 9 +++++++++ + README.md | 2 +- + configure.ac | 2 +- + 3 files changed, 11 insertions(+), 2 deletions(-) + +commit 481bf194cc460db4cbba15dbe06dcd3dcd26719f +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Mon Dec 27 22:11:59 2021 -0800 + + tests: add error tests for concatenated documents + + tests/test-parser.scm | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +commit 5e184c41d60f63a15e526d702db4036d879a915a +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Mon Dec 27 15:42:02 2021 -0800 + + add support for concatenated documents + + Closed #76. + + README.md | 15 ++++++++++++--- + json/parser.scm | 19 ++++++++++++------- + tests/test-parser.scm | 10 +++++++++- + 3 files changed, 33 insertions(+), 11 deletions(-) + +commit 467c0d402c233bc36e7d6bc8c8f0259488603a26 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Mon Dec 27 15:28:42 2021 -0800 + + README: add JSON text sequences documentation + + README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 69 insertions(+), 6 deletions(-) + +commit 52c3f300a53b4a376ffcef02288ff54cafdb66ff +Merge: f034f82 c38640a +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Mon May 24 09:00:17 2021 -0700 + + Merge pull request #75 from sirikid/feature/json-seq + + RFC 7464 JSON Text Sequences + +commit c38640aea2e094c274ea70f901d8592e2d7ef176 +Author: Ivan Sokolov <[email protected]> +Date: Sat May 22 20:22:19 2021 +0300 + + Add tests for json seq parser + + tests/test-parser.scm | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +commit f6ea3ac95eb682f1d8a2371657ace07ea8ab277b +Author: Ivan Sokolov <[email protected]> +Date: Sat May 22 20:21:57 2021 +0300 + + Add tests for json seq builder + + tests/test-builder.scm | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +commit 4591cc12896b1bdf837ffa78a313919cbe3284a2 +Author: Ivan Sokolov <[email protected]> +Date: Thu May 20 13:06:55 2021 +0300 + + Add json seq parser + + json/parser.scm | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 67 insertions(+), 1 deletion(-) + +commit dd578c2b18d48c0195e0769e5d00ca6c750dad40 +Author: Ivan Sokolov <[email protected]> +Date: Wed May 19 02:11:42 2021 +0300 + + Add json seq builder + + json/builder.scm | 28 +++++++++++++++++++++++++++- + 1 file changed, 27 insertions(+), 1 deletion(-) + +commit f034f82f0dd33407ae97f383e7c1f4d82f9e2164 +Merge: 201ea1c 82bf335 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Fri May 21 10:31:35 2021 -0700 + + Merge pull request #74 from sirikid/feature/test-runner + + Make test suites portable accross Guile versions + +commit 82bf33512d2a0341e76140d6a3a016ce1ffa2e5e +Author: Ivan Sokolov <[email protected]> +Date: Fri May 21 20:14:22 2021 +0300 + + Make test suites portable + + tests/test-builder.scm | 4 +++- + tests/test-parser.scm | 4 +++- + tests/test-record.scm | 4 +++- + 3 files changed, 9 insertions(+), 3 deletions(-) + +commit 201ea1cf05b4c604418d76acd1a54739aeade88b +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Fri May 21 10:07:21 2021 -0700 + + README: avoid html elements in markdown + + README.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit b678798fdc90984260b122abd09fe7cc931872d0 +Merge: 7cdda5c c663629 +Author: Aleix Conchillo Flaqu?? <[email protected]> +Date: Fri May 21 10:03:56 2021 -0700 + + Merge pull request #73 from sirikid/feature/test-runner + + Fix #72 + +commit c6636299f523d8dfdf479d4faeb2ac167ca89454 +Author: Ivan Sokolov <[email protected]> +Date: Fri May 21 19:17:00 2021 +0300 + + Simplify test runner + + tests/runner.scm | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +commit 22ed451f86a666c487eeed7958da9fbb3b19df28 +Author: Ivan Sokolov <[email protected]> +Date: Fri May 21 19:16:23 2021 +0300 + + Fix #72 + + tests/test-builder.scm | 4 ++-- + tests/test-parser.scm | 4 ++-- + tests/test-record.scm | 2 +- + 3 files changed, 5 insertions(+), 5 deletions(-) + commit 7cdda5ca9e05fd3f7834c865fe4701f32b885f71 Author: Aleix Conchillo Flaqu?? <[email protected]> Date: Wed Feb 3 13:14:20 2021 -0800 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/INSTALL new/guile-json-4.7.2/INSTALL --- old/guile-json-4.5.2/INSTALL 2021-02-03 22:14:37.000000000 +0100 +++ new/guile-json-4.7.2/INSTALL 2022-06-26 10:37:07.000000000 +0200 @@ -1,8 +1,8 @@ Installation Instructions ************************* - Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software -Foundation, Inc. + Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free +Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -225,7 +225,7 @@ and if that doesn't work, install pre-built binaries of GCC for HP-UX. - HP-UX 'make' updates targets which have the same time stamps as their + HP-UX 'make' updates targets which have the same timestamps as their prerequisites, which makes it generally unusable when shipped generated files such as 'configure' are involved. Use GNU 'make' instead. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/NEWS new/guile-json-4.7.2/NEWS --- old/guile-json-4.5.2/NEWS 2021-02-03 22:13:22.000000000 +0100 +++ new/guile-json-4.7.2/NEWS 2022-06-26 10:34:09.000000000 +0200 @@ -1,4 +1,34 @@ +* Version 4.7.2 (Jun 26, 2022) + + - Fix breaking change introduced in 4.7.1 and properly allow optional nested + records in other records. + (Closes #78, again) + + +* Version 4.7.1 (Apr 19, 2022) + + - Allow optional nested records in other records. Not defined record fields + will be set to *unspecified* as any other value. + (Closes #78) + + +* Version 4.7.0 (Jan 2, 2022) + + - Allow returning ordered JSON objects key/value pairs by using the keyword + argument #:ordered. + (Closes #77) + + +* Version 4.6.0 (Dec 28, 2021) + + - Add support for Concatenated JSON. + (Closes #76) + + - Add support for JSON Text Sequences. + (thanks to Ivan Sokolov) + + * Version 4.5.2 (Feb 3, 2021) - Add missing modules to record.scm. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/README new/guile-json-4.7.2/README --- old/guile-json-4.5.2/README 2021-02-03 22:13:50.000000000 +0100 +++ new/guile-json-4.7.2/README 2022-06-26 10:34:38.000000000 +0200 @@ -6,6 +6,10 @@ - Complies with http://json.org specification. +- Supports JSON Text Sequences (RFC 7464). + +- Supports parsing concatenated JSON documents. + - Builds JSON documents programmatically using scheme data types. - Allows JSON pretty printing. @@ -15,7 +19,7 @@ Download the latest tarball and untar it: -- [guile-json-4.5.2.tar.gz](https://download.savannah.gnu.org/releases/guile-json/guile-json-4.5.2.tar.gz) +- [guile-json-4.7.2.tar.gz](https://download.savannah.gnu.org/releases/guile-json/guile-json-4.7.2.tar.gz) If you are cloning the repository make sure you run this first: @@ -27,7 +31,7 @@ $ make $ sudo make install -Where <guile-prefix> should preferably be the same as your system Guile +Where `<guile-prefix>` should preferably be the same as your system Guile installation directory (e.g. /usr). If everything installed successfully you should be up and running: @@ -75,10 +79,10 @@ scheme@(guile-user)> (use-modules (json)) -## Procedures +## Reading JSON documents -- (**json->scm** #:optional port #:key null) : Reads a JSON document from the - given port, or from the current input port if none is given. +- (**json->scm** #:optional port #:key null ordered concatenated) : Reads a JSON + document from the given port, or from the current input port if none is given. Optional arguments: @@ -88,13 +92,27 @@ - *null* : value for JSON's null, it defaults to the 'null symbol. -- (**json-string->scm** str #:key null) : Reads a JSON document from the given - string. + - *ordered* : indicate whether JSON objects order should be preserved or not + (the default). + + - *concatenated* : if true it tells the parser that more JSON documents might + be present after a properly parsed document, otherwise the parser will fail + if additional data is present after the first document (this is the + default). + +- (**json-string->scm** str #:key null ordered) : Reads a JSON document from the + given string. Keyword arguments: - *null* : value for JSON's null, it defaults to the 'null symbol. + - *ordered* : indicate whether JSON objects order should be preserved or not + (the default). + + +## Building JSON documents + - (**scm->json** native #:optional port #:key solidus unicode null validate pretty) : Creates a JSON document from the given native Guile value. The JSON document is written into the given port, or to the current output port if non @@ -121,13 +139,76 @@ false). - (**scm->json-string** native #:key solidus unicode null validate pretty) : - Creates a JSON document from the given native Guile value into a string. For - keyword arguments meaning see *scm->json*. + Creates a JSON document from the given native Guile value into a string. + + See keyword arguments for *scm->json*. Note that when using alists to build JSON objects, symbols or numbers might be used as keys and they both will be converted to strings. +## Reading JSON Text Sequences + +- (**json-seq->scm** #:optional port #:key null ordered handle-truncate + truncated-object) : Reads a stream of JSON documents from the given port, or + from the current input port if none is given. + + Optional arguments: + + - *port* : is optional, it defaults to the current input port. + + Keyword arguments: + + - *null* : value for JSON's null, it defaults to the 'null symbol. + + - *ordered* : indicate whether JSON objects order should be preserved or not + (the default). + + - *handle-truncate* : defines how to handle data loss. Possible values: + + - *'throw*: throw an exception. + - *'stop*: stop parsing and end the stream. + - *'skip*: skip corrupted fragment and return next object (default). + - *'replace*: skip corrupted fragment and return object specific by + *truncated-object*. + + - *truncated-object* : use this object if an object could not be parsed (to be + used when setting *handle-truncate* to *'replace* value). + +- (**json-seq-string->scm** str #:key null ordered handle-truncate + truncated-object) : Reads a stream of JSON documents from the given string. + + See keyword arguments for *json-seq->scm*. + + +## Building JSON Text Sequences + +- (**scm->json-seq** objects #:optional port #:key solidus null validate) : + Creates a JSON document sequence from the given list of native Guile + objects. The JSON document sequence is written into the given port, or to the + current output port if non is given. + + Optional arguments: + + - *port* : it defaults to the current output port. + + Keyword arguments: + + - *solidus* : if true, the slash (/ solidus) character will be escaped + (defaults to false). + + - *null* : value for JSON's null (defaults to the 'null symbol). + + - *validate* : if true, the native value will be validated before starting + to print the JSON document (defaults to true). + +- (**scm->json-seq-string** objects #:key solidus null validate) : Creates a + JSON document sequence from the given list of native Guile objects into a + string. + + See keyword arguments for *scm->json-seq*. + + ## Exceptions A *json-invalid* exception is thrown if an error is found during the JSON @@ -268,8 +349,10 @@ ### Records and null fields -When serializing a record to JSON it is possible to set a field to the -\*unspecified\* value in order to omit it from serialization. +When serializing a record to a JSON object it is possible to set a field to the +\*unspecified\* value in order to omit it from serialization. Also, when +deserializing a JSON object to a record, missing record fields in the JSON +object will be set to \*unspecified\* in the record. # Examples @@ -334,7 +417,7 @@ # License -Copyright (C) 2013-2021 Aleix Conchillo Flaque <[email protected]> +Copyright (C) 2013-2022 Aleix Conchillo Flaque <[email protected]> guile-json is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/build-aux/missing new/guile-json-4.7.2/build-aux/missing --- old/guile-json-4.5.2/build-aux/missing 2021-02-03 22:14:37.000000000 +0100 +++ new/guile-json-4.7.2/build-aux/missing 2022-06-26 10:37:07.000000000 +0200 @@ -3,7 +3,7 @@ scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <[email protected]>, 1996. # This program is free software; you can redistribute it and/or modify diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/build-aux/test-driver new/guile-json-4.7.2/build-aux/test-driver --- old/guile-json-4.5.2/build-aux/test-driver 2021-02-03 22:14:37.000000000 +0100 +++ new/guile-json-4.7.2/build-aux/test-driver 2022-06-26 10:37:07.000000000 +0200 @@ -3,7 +3,7 @@ scriptversion=2018-03-07.03; # UTC -# Copyright (C) 2011-2020 Free Software Foundation, Inc. +# Copyright (C) 2011-2021 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -105,8 +105,11 @@ trap "st=141; $do_exit" 13 trap "st=143; $do_exit" 15 -# Test script is run here. -"$@" >$log_file 2>&1 +# Test script is run here. We create the file first, then append to it, +# to ameliorate tests themselves also writing to the log file. Our tests +# don't, but others can (automake bug#35762). +: >"$log_file" +"$@" >>"$log_file" 2>&1 estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then @@ -128,7 +131,7 @@ # know whether the test passed or failed simply by looking at the '.log' # file, without the need of also peaking into the corresponding '.trs' # file (automake bug#11814). -echo "$res $test_name (exit status: $estatus)" >>$log_file +echo "$res $test_name (exit status: $estatus)" >>"$log_file" # Report outcome to console. echo "${col}${res}${std}: $test_name" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/configure.ac new/guile-json-4.7.2/configure.ac --- old/guile-json-4.5.2/configure.ac 2021-02-03 22:13:39.000000000 +0100 +++ new/guile-json-4.7.2/configure.ac 2022-06-26 10:34:21.000000000 +0200 @@ -1,7 +1,7 @@ # # configure.ac # -# Copyright (C) 2013-2021 Aleix Conchillo Flaque <[email protected]> +# Copyright (C) 2013-2022 Aleix Conchillo Flaque <[email protected]> # # This file is part of guile-json. # @@ -19,7 +19,7 @@ # along with guile-json. If not, see https://www.gnu.org/licenses/. # -AC_INIT([guile-json], [4.5.2], [[email protected]]) +AC_INIT([guile-json], [4.7.2], [[email protected]]) AC_CONFIG_MACRO_DIRS([m4]) AC_CONFIG_SRCDIR(json.scm) AC_CONFIG_AUX_DIR([build-aux]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/json/builder.scm new/guile-json-4.7.2/json/builder.scm --- old/guile-json-4.5.2/json/builder.scm 2020-10-05 23:21:11.000000000 +0200 +++ new/guile-json-4.7.2/json/builder.scm 2022-04-19 05:55:35.000000000 +0200 @@ -30,7 +30,9 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-43) #:export (scm->json - scm->json-string)) + scm->json-string + scm->json-seq + scm->json-seq-string)) ;; @@ -251,4 +253,28 @@ #:solidus solidus #:unicode unicode #:null null #:pretty pretty #:validate validate)))) +(define* (scm->json-seq objects #:optional (port (current-output-port)) + #:key (null 'null) (solidus #f) (validate #t)) + "Create a JSON text sequence from native @var{objects} and write it. +The optional argument @var{port} specifies the output port, which defaults to +the current output port. This procedure also takes a subset of +@code{json->scm} keyword arguments - @{null}, @{solidus} and @{validate}. +@{unicode} and @{pretty} are unsupported because RFC 7464 requires JSON text +sequences to be written in UTF-8, one per line." + (define (put-entry object) + (put-char port #\rs) + (scm->json object port + #:unicode #t #:null null #:solidus solidus #:validate validate) + (put-char port #\lf)) + (for-each put-entry objects)) + +(define* (scm->json-seq-string objects + #:key (null 'null) (solidus #f) (validate #t)) + "Create a JSON text sequence from native @var{objects} and return it. +This procedure takes the same keyword arguments as @code{scm->json-seq}." + (call-with-output-string + (lambda (port) + (scm->json-seq objects port + #:null null #:solidus solidus #:validate validate)))) + ;;; (json builder) ends here diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/json/parser.scm new/guile-json-4.7.2/json/parser.scm --- old/guile-json-4.5.2/json/parser.scm 2020-12-07 00:12:28.000000000 +0100 +++ new/guile-json-4.7.2/json/parser.scm 2022-04-19 05:55:35.000000000 +0200 @@ -24,8 +24,13 @@ ;;; Code: (define-module (json parser) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 streams) + #:use-module (rnrs io ports) #:export (json->scm - json-string->scm)) + json-string->scm + json-seq->scm + json-seq-string->scm)) ;; ;; Miscellaneuos helpers @@ -73,6 +78,11 @@ ;; Unexpected EOF. ((eof-object? ch) (json-exception port))))) +(define (skip-record-separators port) + (when (eqv? #\rs (peek-char port)) + (read-char port) + (skip-record-separators port))) + ;; ;; Number parsing helpers ;; @@ -187,7 +197,7 @@ ;; Object parsing helpers ;; -(define (read-pair port null) +(define (read-pair port null ordered) ;; Read key. (let ((key (json-read-string port))) (skip-whitespaces port) @@ -196,11 +206,11 @@ ;; Skip colon and read value. ((eqv? ch #\:) (read-char port) - (cons key (json-read port null))) + (cons key (json-read port null ordered))) ;; Anything other than colon is an error. (else (json-exception port)))))) -(define (json-read-object port null) +(define (json-read-object port null ordered) (expect-delimiter port #\{) (let loop ((pairs '()) (added #t)) (skip-whitespaces port) @@ -210,11 +220,11 @@ ((eqv? ch #\}) (read-char port) (cond - (added pairs) + (added (if ordered (reverse! pairs) pairs)) (else (json-exception port)))) ;; Read one pair and continue. ((eqv? ch #\") - (let ((pair (read-pair port null))) + (let ((pair (read-pair port null ordered))) (loop (cons pair pairs) #t))) ;; Skip comma and read more pairs. ((eqv? ch #\,) @@ -229,7 +239,7 @@ ;; Array parsing helpers ;; -(define (json-read-array port null) +(define (json-read-array port null ordered) (expect-delimiter port #\[) (skip-whitespaces port) (cond @@ -239,7 +249,7 @@ #()) (else ;; Read first element in array. - (let loop ((values (list (json-read port null)))) + (let loop ((values (list (json-read port null ordered)))) (skip-whitespaces port) (let ((ch (peek-char port))) (cond @@ -248,7 +258,7 @@ ;; Handle comma (if there's a comma there should be another element). ((eqv? ch #\,) (read-char port) - (loop (cons (json-read port null) values))) + (loop (cons (json-read port null ordered) values))) ;; End of array. ((eqv? ch #\]) (read-char port) @@ -362,7 +372,7 @@ ;; Main parser functions ;; -(define (json-read port null) +(define (json-read port null ordered) (skip-whitespaces port) (let ((ch (peek-char port))) (cond @@ -372,8 +382,8 @@ ((eqv? ch #\t) (json-read-true port)) ((eqv? ch #\f) (json-read-false port)) ((eqv? ch #\n) (json-read-null port null)) - ((eqv? ch #\{) (json-read-object port null)) - ((eqv? ch #\[) (json-read-array port null)) + ((eqv? ch #\{) (json-read-object port null ordered)) + ((eqv? ch #\[) (json-read-array port null ordered)) ((eqv? ch #\") (json-read-string port)) ;; Anything else should be a number. (else (json-read-number port))))) @@ -383,24 +393,90 @@ ;; (define* (json->scm #:optional (port (current-input-port)) - #:key (null 'null)) + #:key (null 'null) (ordered #f) (concatenated #f)) "Parse a JSON document into native. Takes one optional argument, @var{port}, which defaults to the current input port from where the JSON -document is read. It also takes a keyword argument: @{null}: value for JSON's -null, it defaults to the 'null symbol." - (let ((value (json-read port null))) +document is read. It also takes a few of keyword arguments: @{null}: value for +JSON's null, it defaults to the 'null symbol, @{ordered} to indicate whether +JSON objects order should be preserved or not (the default) and @{concatenated} +which can be used to tell the parser that more JSON documents might come after a +properly parsed document." + (let loop ((value (json-read port null ordered))) ;; Skip any trailing whitespaces. (skip-whitespaces port) (cond ;; If we reach the end the parsing succeeded. ((eof-object? (peek-char port)) value) - ;; If there's anything else other than the end, parser fails. - (else (json-exception port))))) + ;; If there's anything else other than the end, check if user wants to keep + ;; parsing concatenated valid JSON documents, otherwise parser fails. + (else + (cond (concatenated value) + (else (json-exception port))))))) -(define* (json-string->scm str #:key (null 'null)) +(define* (json-string->scm str #:key (null 'null) (ordered #f)) "Parse a JSON document into native. Takes a string argument, -@var{str}, that contains the JSON document. It also takes a keyword argument: -@{null}: value for JSON's null, it defaults to the 'null symbol " - (call-with-input-string str (lambda (p) (json->scm p #:null null)))) +@var{str}, that contains the JSON document. It also takes a couple of keyword +argument: @{null}: value for JSON's null, it defaults to the 'null symbol and +@{ordered} to indicate whether JSON objects order should be preserved or +not (the default)." + (call-with-input-string str (lambda (p) (json->scm p #:null null #:ordered ordered)))) + +(define* (json-seq->scm #:optional (port (current-input-port)) + #:key (null 'null) (ordered #f) + (handle-truncate 'skip) (truncated-object 'truncated)) + "Lazy parse a JSON text sequence from the port @var{port}. +This procedure returns a stream of parsed documents. The optional argument +@var{port} defines the port to read from and defaults to the current input +port. It also takes a few keyword arguments: @{null}: value for JSON's null +(defaults to the 'null symbol), @{ordered} to indicate whether JSON objects +order should be preserved or not (the default), @{handle-truncate}: defines how +to handle data loss, @{truncated-object}: used to replace unparsable +objects. Allowed values for @{handle-truncate} argument are 'throw (throw an +exception), 'stop (stop parsing and end the stream), 'skip (default, skip +corrupted fragment and return the next entry), 'replace (skip corrupted fragment +and return @{truncated-object} instead)." + (letrec ((handle-truncation + (case handle-truncate + ((throw) (json-exception port)) + ((stop) (const (eof-object))) + ((skip) + (lambda (port) + (read-delimited "\x1e" port 'peek) + (read-entry port))) + ((replace) + (lambda (port) + (read-delimited "\x1e" port 'peek) + truncated-object)))) + (read-entry + (lambda (port) + (let ((ch (read-char port))) + (cond + ((eof-object? ch) ch) + ((not (eqv? ch #\rs)) + (handle-truncation port)) + (else + (skip-record-separators port) + (catch 'json-invalid + (lambda () + (let ((next (json-read port null ordered))) + (if (eqv? #\lf (peek-char port)) + (begin + (read-char port) + next) + (handle-truncation port)))) + (lambda (_ port) + (handle-truncation port))))))))) + (port->stream port read-entry))) + +(define* (json-seq-string->scm str #:key (null 'null) (ordered #f) + (handle-truncate 'skip) (truncated-object 'truncated)) + "Lazy parse a JSON text sequence from the string @var{str}. +This procedure returns a stream of parsed documents and also takes the same +keyword arguments as @code{json-seq->scm}." + (call-with-input-string str + (lambda (p) + (json-seq->scm p #:null null #:ordered ordered + #:handle-truncate handle-truncate + #:truncated-object truncated-object)))) ;;; (json parser) ends here diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/json/record.scm new/guile-json-4.7.2/json/record.scm --- old/guile-json-4.5.2/json/record.scm 2021-02-03 22:04:39.000000000 +0100 +++ new/guile-json-4.7.2/json/record.scm 2022-06-26 10:40:26.000000000 +0200 @@ -64,7 +64,7 @@ (define (record->json record) (let-syntax ((extract-field (syntax-rules () ((_ (field getter key scm->value value->scm)) - (cons key (value->scm (getter record)))) + (cons key (if (unspecified? (getter record)) *unspecified* (value->scm (getter record))))) ((_ (field getter key scm->value)) (cons key (getter record))) ((_ (field getter key)) @@ -97,7 +97,7 @@ (define (record->scm record) (let-syntax ((extract-field (syntax-rules () ((_ (field getter key scm->value value->scm)) - (cons key (value->scm (getter record)))) + (cons key (if (unspecified? (getter record)) *unspecified* (value->scm (getter record))))) ((_ (field getter key scm->value)) (cons key (getter record))) ((_ (field getter key)) @@ -112,7 +112,7 @@ "Define RTD as a record type with the given FIELDs and GETTERs, ?? la SRFI-9, and define JSON->RECORD as a conversion from JSON (from a port, string or alist) to a record of this type. Optionally, define RECORD->JSON as a conversion from a -record of this type to a JSON string. Additionaly, define SCM->RECORD as a +record of this type to a JSON string. Additionally, define SCM->RECORD as a conversion from an alist to a record of this type (equivalent to JSON->RECORD when passing an alist) and RECORD->SCM as a conversion from a record of this type to an alist." @@ -205,9 +205,13 @@ #,(gen-id #'rtd (cleanup-rtd #'rtd) "-" #'name) key #,(if (vector? (syntax->datum #'field-rtd)) - #`(lambda (v) (map #,(gen-id #'field-rtd "scm->" (cleanup-rtd #'field-rtd)) - (vector->list v))) - (gen-id #'field-rtd "scm->" (cleanup-rtd #'field-rtd))) + #`(lambda (v) (if (unspecified? v) + *unspecified* + (map #,(gen-id #'field-rtd "scm->" (cleanup-rtd #'field-rtd)) + (vector->list v)))) + #`(lambda (v) (if (unspecified? v) + *unspecified* + #,(gen-id #'field-rtd "scm->" (cleanup-rtd #'field-rtd))))) #,(if (vector? (syntax->datum #'field-rtd)) #`(lambda (v) (list->vector diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/tests/runner.scm new/guile-json-4.7.2/tests/runner.scm --- old/guile-json-4.5.2/tests/runner.scm 2020-04-08 09:14:06.000000000 +0200 +++ new/guile-json-4.7.2/tests/runner.scm 2022-04-19 05:55:35.000000000 +0200 @@ -28,9 +28,7 @@ #:export (json:test-runner)) (define (json:test-runner) - (let ((runner (test-runner-null)) - (num-passed 0) - (num-failed 0)) + (let ((runner (test-runner-null))) (test-runner-on-test-end! runner (lambda (runner) (format #t "[~a] line:~a, test: ~a\n" @@ -38,20 +36,19 @@ (test-result-ref runner 'source-line) (test-runner-test-name runner)) (case (test-result-kind runner) - ((pass xpass) (set! num-passed (1+ num-passed))) ((fail xfail) (if (test-result-ref runner 'expected-value) (format #t "~a\n -> expected: ~s\n -> obtained: ~s\n" (string-join (test-runner-group-path runner) "/") (test-result-ref runner 'expected-value) - (test-result-ref runner 'actual-value))) - (set! num-failed (1+ num-failed))) + (test-result-ref runner 'actual-value)))) (else #t)))) (test-runner-on-final! runner (lambda (runner) (format #t "Source:~a\npass = ~a, fail = ~a\n" - (test-result-ref runner 'source-file) num-passed num-failed) - (zero? num-failed))) + (test-result-ref runner 'source-file) + (test-runner-pass-count runner) + (test-runner-fail-count runner)))) runner)) ;;; (tests runner) ends here diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/tests/test-builder.scm new/guile-json-4.7.2/tests/test-builder.scm --- old/guile-json-4.5.2/tests/test-builder.scm 2020-10-05 23:21:11.000000000 +0200 +++ new/guile-json-4.7.2/tests/test-builder.scm 2022-04-19 05:55:35.000000000 +0200 @@ -24,8 +24,8 @@ ;;; Code: (define-module (tests test-builder) - #:use-module (srfi srfi-64) #:use-module (json) + #:use-module (srfi srfi-64) #:use-module (tests runner)) (test-runner-factory json:test-runner) @@ -122,6 +122,22 @@ (test-error #t (scm->json #(1 +inf.0 3))) (test-error #t (scm->json '((foo . +nan.0)))) -(exit (if (test-end "test-builder") 0 1)) +;; Sequences +(test-equal "\x1e[]\n" (scm->json-seq-string '(#()))) +(test-equal "\x1enull\n" (scm->json-seq-string '(null))) +(test-equal "\x1enull\n" (scm->json-seq-string '(ball) #:null 'ball)) +(test-equal "\x1e1\n\x1e2\n\x1e3\n\x1e[1,2,3]\n" (scm->json-seq-string '(1 2 3 #(1 2 3)))) +(test-equal "\x1e{\"foo\":{\"bar\":{\"baz\":true}}}\n" (scm->json-seq-string '(((foo . (("bar" . ((baz . #t))))))))) + +(test-equal "\x1e\"\\u001e\"\n" (scm->json-seq-string (list "\x1e"))) + +(test-error #t (scm->json-seq (list (vector 1 2 3 #u8(1 2 3))))) +(test-error #t (scm->json-seq '(#u8(1 2 3)))) +(test-error #t (scm->json-seq '(#(1 +inf.0 3)))) +(test-error #t (scm->json-seq '(((foo . +nan.0))))) + +(let ((fail-count (test-runner-fail-count (test-runner-current)))) + (test-end "test-builder") + (exit (zero? fail-count))) ;;; (tests test-builder) ends here diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/tests/test-parser.scm new/guile-json-4.7.2/tests/test-parser.scm --- old/guile-json-4.5.2/tests/test-parser.scm 2020-11-29 06:37:22.000000000 +0100 +++ new/guile-json-4.7.2/tests/test-parser.scm 2022-04-19 05:55:35.000000000 +0200 @@ -1,6 +1,6 @@ ;;; (tests test-parser) --- Guile JSON implementation. -;; Copyright (C) 2018-2020 Aleix Conchillo Flaque <[email protected]> +;; Copyright (C) 2018-2022 Aleix Conchillo Flaque <[email protected]> ;; ;; This file is part of guile-json. ;; @@ -24,8 +24,9 @@ ;;; Code: (define-module (tests test-parser) - #:use-module (srfi srfi-64) + #:use-module (ice-9 streams) #:use-module (json) + #:use-module (srfi srfi-64) #:use-module (tests runner)) (test-runner-factory json:test-runner) @@ -97,6 +98,10 @@ (test-error #t (json-string->scm "{,}")) (test-error #t (json-string->scm "{")) +;; Objects (ordered) +(test-equal '() (json-string->scm "{}" #:ordered #t)) +(test-equal '(("green" . 1) ("eggs" . 2) ("ham" . 3)) (json-string->scm "{\"green\":1, \"eggs\":2, \"ham\":3}" #:ordered #t)) + ;; Since the following JSON object contains more than one key-value pair, we ;; can't use "test-equal" directly since the output could be unordered. (define book (json-string->scm "{\"title\":\"A book\",\"author\":\"An author\",\"price\":29.99}")) @@ -111,6 +116,40 @@ (test-error #t (json-string->scm "[1,2,3] extra")) (test-error #t (json-string->scm "{} extra")) -(exit (if (test-end "test-parser") 0 1)) +;; Concatenated documents +(call-with-input-string "{}12345 \"concatenated\" {\"foo\":\"bar\"}" + (lambda (p) + (test-equal '() (json->scm p #:concatenated #t)) + (test-equal '12345 (json->scm p #:concatenated #t)) + (test-equal "concatenated" (json->scm p #:concatenated #t)) + (test-equal '(("foo" . "bar")) (json->scm p #:concatenated #t)) + (test-error #t (json->scm p #:concatenated #t)))) + +(call-with-input-string "{} \"foo\" bar" + (lambda (p) + (test-equal '() (json->scm p #:concatenated #t)) + (test-equal "foo" (json->scm p #:concatenated #t)) + (test-error #t (json->scm p #:concatenated #t)))) + +(call-with-input-string "{" + (lambda (p) + (test-error #t (json->scm p #:concatenated #t)))) + +;; Sequences +(define stream (json-seq-string->scm "\x1e1\n\x1e{}\n\x1e[null,true,false]\n\x1e{data loss" + #:handle-truncate 'replace)) +(test-equal 1 (stream-car stream)) +(test-equal '() (stream-car (stream-cdr stream))) +(test-equal #(null #t #f) (stream-car (stream-cdr (stream-cdr stream)))) +(test-equal 'truncated (stream-car (stream-cdr (stream-cdr (stream-cdr stream))))) +(test-assert (stream-null? (stream-cdr (stream-cdr (stream-cdr (stream-cdr stream)))))) + +(test-assert (stream-null? (json-seq-string->scm "\x1enull\x1enull\x1enull" #:handle-truncate 'skip))) + +(test-equal "\x1e" (stream-car (json-seq-string->scm "\x1e\"\\u001e\"\n"))) + +(let ((fail-count (test-runner-fail-count (test-runner-current)))) + (test-end "test-parser") + (exit (zero? fail-count))) ;;; (tests test-parser) ends here diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/guile-json-4.5.2/tests/test-record.scm new/guile-json-4.7.2/tests/test-record.scm --- old/guile-json-4.5.2/tests/test-record.scm 2021-01-11 18:30:37.000000000 +0100 +++ new/guile-json-4.7.2/tests/test-record.scm 2022-04-19 07:00:52.000000000 +0200 @@ -1,6 +1,6 @@ ;;; (tests test-record) --- Guile JSON implementation. -;; Copyright (C) 2020-2021 Aleix Conchillo Flaque <[email protected]> +;; Copyright (C) 2020-2022 Aleix Conchillo Flaque <[email protected]> ;; ;; This file is part of guile-json. ;; @@ -189,6 +189,31 @@ (test-equal "{\"id\":\"11111\",\"username\":\"jane\",\"link\":{\"type\":\"test\",\"url\":\"http://guile.json\"}}" (account-type->json test-account-type)) +;; Check JSON types with optional nested objects. + +(define-json-type <omitted-type> + (name)) + +(define-json-type <account-type> + (id) + (username) + (omitted "omitted" <omitted-type>)) + +(define test-json-account + "{\"id\":\"11111\",\"username\":\"jane\"}") + +(define test-account-type (json->account-type test-json-account)) + +(test-equal "11111" (account-type-id test-account-type)) +(test-equal "jane" (account-type-username test-account-type)) +(test-equal *unspecified* (account-type-omitted test-account-type)) + +(test-equal (make-account-type "11111" "jane" *unspecified*) + (json->account-type (account-type->json test-account-type))) + +(test-equal (make-account-type "11111" "jane" *unspecified*) + (scm->account-type (account-type->scm test-account-type))) + ;; Check JSON types with vectors. (define-json-type <account-type> @@ -206,6 +231,8 @@ (test-equal "{\"id\":\"11111\",\"username\":\"jane\",\"links\":[{\"type\":\"test\",\"url\":\"http://guile.json\"}]}" (account-type->json test-account-type)) -(exit (if (test-end "test-record") 0 1)) +(let ((fail-count (test-runner-fail-count (test-runner-current)))) + (test-end "test-record") + (exit (zero? fail-count))) ;;; (tests test-record) ends here
