Merge lp:~zorba-coders/zorba/remove_old_json into lp:~zorba-coders/zorba/data-converters-module

Proposed by Paul J. Lucas
Status: Merged
Approved by: Chris Hillery
Approved revision: 80
Merged at revision: 80
Proposed branch: lp:~zorba-coders/zorba/remove_old_json
Merge into: lp:~zorba-coders/zorba/data-converters-module
Diff against target: 3082 lines (+0/-2529)
98 files modified
cmake_modules/FindJansson.cmake (+0/-64)
src/com/zorba-xquery/www/modules/converters/CMakeLists.txt (+0/-35)
src/com/zorba-xquery/www/modules/converters/json-options.xsd (+0/-47)
src/com/zorba-xquery/www/modules/converters/json.xq (+0/-242)
src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp (+0/-729)
src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.h (+0/-56)
src/com/zorba-xquery/www/modules/converters/json.xq.src/json.cpp (+0/-317)
src/com/zorba-xquery/www/modules/converters/json.xq.src/json.h (+0/-167)
src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.cpp (+0/-153)
src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.h (+0/-49)
test_json/ExpQueryResults/converters/jansson/parse_json_01.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_02.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_03.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_06.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_07.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_08.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_09.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_10.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_11.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_ml_01.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_ml_02.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_ml_05.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_01.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_02.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_04.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_05.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_09.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_10.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_13.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_14.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_15.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_16.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_17.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_18.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_ml_01.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_ml_02.xml.res (+0/-1)
test_json/ExpQueryResults/converters/jansson/serialize_json_ml_04.xml.res (+0/-1)
test_json/Queries/converters/jansson/parse_json_01.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_01.xq (+0/-22)
test_json/Queries/converters/jansson/parse_json_02.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_02.xq (+0/-37)
test_json/Queries/converters/jansson/parse_json_03.xq (+0/-8)
test_json/Queries/converters/jansson/parse_json_04.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_04.xq (+0/-8)
test_json/Queries/converters/jansson/parse_json_05.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_05.xq (+0/-14)
test_json/Queries/converters/jansson/parse_json_06.xq (+0/-8)
test_json/Queries/converters/jansson/parse_json_07.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_07.xq (+0/-13)
test_json/Queries/converters/jansson/parse_json_08.xq (+0/-8)
test_json/Queries/converters/jansson/parse_json_09.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_09.xq (+0/-26)
test_json/Queries/converters/jansson/parse_json_10.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_10.xq (+0/-40)
test_json/Queries/converters/jansson/parse_json_11.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_11.xq (+0/-20)
test_json/Queries/converters/jansson/parse_json_12.xq (+0/-4)
test_json/Queries/converters/jansson/parse_json_ml_01.xq (+0/-27)
test_json/Queries/converters/jansson/parse_json_ml_02.xq (+0/-65)
test_json/Queries/converters/jansson/parse_json_ml_03.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_ml_03.xq (+0/-8)
test_json/Queries/converters/jansson/parse_json_ml_04.spec (+0/-1)
test_json/Queries/converters/jansson/parse_json_ml_04.xq (+0/-16)
test_json/Queries/converters/jansson/parse_json_ml_05.xq (+0/-24)
test_json/Queries/converters/jansson/parse_json_ml_06.xq (+0/-7)
test_json/Queries/converters/jansson/serialize_json_01.xq (+0/-9)
test_json/Queries/converters/jansson/serialize_json_02.xq (+0/-8)
test_json/Queries/converters/jansson/serialize_json_03.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_03.xq (+0/-8)
test_json/Queries/converters/jansson/serialize_json_04.xq (+0/-10)
test_json/Queries/converters/jansson/serialize_json_05.xq (+0/-10)
test_json/Queries/converters/jansson/serialize_json_06.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_06.xq (+0/-10)
test_json/Queries/converters/jansson/serialize_json_07.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_07.xq (+0/-10)
test_json/Queries/converters/jansson/serialize_json_08.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_08.xq (+0/-12)
test_json/Queries/converters/jansson/serialize_json_09.xq (+0/-15)
test_json/Queries/converters/jansson/serialize_json_10.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_10.xq (+0/-15)
test_json/Queries/converters/jansson/serialize_json_11.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_11.xq (+0/-10)
test_json/Queries/converters/jansson/serialize_json_12.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_12.xq (+0/-10)
test_json/Queries/converters/jansson/serialize_json_13.xq (+0/-16)
test_json/Queries/converters/jansson/serialize_json_14.xq (+0/-16)
test_json/Queries/converters/jansson/serialize_json_15.xq (+0/-13)
test_json/Queries/converters/jansson/serialize_json_16.xq (+0/-14)
test_json/Queries/converters/jansson/serialize_json_17.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_17.xq (+0/-23)
test_json/Queries/converters/jansson/serialize_json_18.xq (+0/-7)
test_json/Queries/converters/jansson/serialize_json_ml_01.xq (+0/-12)
test_json/Queries/converters/jansson/serialize_json_ml_02.xq (+0/-21)
test_json/Queries/converters/jansson/serialize_json_ml_03.spec (+0/-1)
test_json/Queries/converters/jansson/serialize_json_ml_03.xq (+0/-8)
test_json/Queries/converters/jansson/serialize_json_ml_04.xq (+0/-10)
To merge this branch: bzr merge lp:~zorba-coders/zorba/remove_old_json
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+89770@code.launchpad.net

Commit message

Removed old JSON module.

Description of the change

Removed old JSON module.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/remove_old_json into lp:zorba/data-converters-module failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job remove_old_json-2012-01-23T19-46-43.722Z is finished.
  The final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job remove_old_json-2012-01-24T01-34-37.367Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'cmake_modules/FindJansson.cmake'
--- cmake_modules/FindJansson.cmake 2011-10-06 07:40:17 +0000
+++ cmake_modules/FindJansson.cmake 1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
1# Copyright 2006-2008 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# - Find Jansson
16#
17# Once done this will define
18#
19# Jansson_FOUND - System has Jansson
20# Jansson_INCLUDE_DIRS - The Jansson include directories
21# Jansson_LIBRARIES - The libraries needed to use Jansson
22
23IF (Jansson_INCLUDE AND Jansson_LIBRARY)
24 # in cache already
25 SET(Jansson_FIND_QUIETLY TRUE)
26ENDIF (Jansson_INCLUDE AND Jansson_LIBRARY)
27
28SET(LIBRARY_NAMES jansson jansson.lib Release/jansson.lib bin/jansson.lib bin/Release/jansson.lib)
29FIND_LIBRARY(
30 Jansson_LIBRARY
31 NAMES ${LIBRARY_NAMES}
32 PATHS /usr/lib /usr/local/lib /opt/local/lib ${Jansson_LIBRARIES})
33
34FIND_PATH(
35 Jansson_INCLUDE
36 NAMES jansson.h
37 PATH_SUFFIXES jansson src
38 PATHS ${Jansson_INCLUDE_DIRS})
39
40IF(Jansson_LIBRARY AND Jansson_INCLUDE)
41 SET(Jansson_FOUND TRUE)
42 SET(Jansson_LIBRARIES ${Jansson_LIBRARY})
43 SET(Jansson_INCLUDE_DIRS ${Jansson_INCLUDE})
44ELSE(Jansson_LIBRARY AND Jansson_INCLUDE)
45 IF(NOT Jansson_LIBRARY)
46 MESSAGE(STATUS "Jansson static library could not be found matching one of: ${LIBRARY_NAMES}")
47 ENDIF(NOT Jansson_LIBRARY)
48 IF(NOT Jansson_INCLUDE)
49 MESSAGE(STATUS "Jansson source directory could not be found.")
50 ENDIF(NOT Jansson_INCLUDE)
51
52 SET(Jansson_FOUND FALSE)
53 SET(Jansson_LIBRARIES)
54 SET(Jansson_INCLUDE)
55ENDIF (Jansson_LIBRARY AND Jansson_INCLUDE)
56
57IF(Jansson_FOUND)
58 IF(NOT Jansson_FIND_QUIETLY)
59 MESSAGE(STATUS "Found Jansson : ${Jansson_LIBRARY}")
60 MESSAGE(STATUS "Found Jansson include path : ${Jansson_INCLUDE_DIRS}")
61 ENDIF(NOT Jansson_FIND_QUIETLY)
62ELSE(Jansson_FOUND)
63 MESSAGE(STATUS "Could not find Jansson library.")
64ENDIF(Jansson_FOUND)
650
=== modified file 'src/com/zorba-xquery/www/modules/converters/CMakeLists.txt'
--- src/com/zorba-xquery/www/modules/converters/CMakeLists.txt 2011-12-06 08:05:27 +0000
+++ src/com/zorba-xquery/www/modules/converters/CMakeLists.txt 2012-01-23 19:42:25 +0000
@@ -40,40 +40,6 @@
40ENDIF (ZORBA_SUPPRESS_LIBTIDY)40ENDIF (ZORBA_SUPPRESS_LIBTIDY)
41MESSAGE (STATUS "")41MESSAGE (STATUS "")
4242
43
44#
45# Jansson
46#
47IF (ZORBA_SUPPRESS_JANSSON)
48 MESSAGE (STATUS "ZORBA_SUPPRESS_JANSSON is true - not searching for Jansson.")
49ELSE (ZORBA_SUPPRESS_JANSSON)
50
51 MESSAGE (STATUS "Looking for Jansson")
52 FIND_PACKAGE (Jansson)
53
54 IF (Jansson_FOUND)
55 MESSAGE (STATUS "Found Jansson library -- " ${Jansson_LIBRARIES})
56
57 SET (JSON_LINK_LIBRARIES ${Jansson_LIBRARIES})
58 INCLUDE_DIRECTORIES (${Jansson_INCLUDE_DIRS})
59 INCLUDE_DIRECTORIES ("json.xq.src")
60 DECLARE_ZORBA_SCHEMA (FILE "json-options.xsd"
61 URI "http://www.zorba-xquery.com/modules/converters/json-options")
62 DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/converters/json" VERSION 1.0 FILE "json.xq" LINK_LIBRARIES "${Jansson_LIBRARIES}")
63 ADD_TEST_DIRECTORY ("${PROJECT_SOURCE_DIR}/test_json")
64
65 IF(ZORBA_NO_UNICODE)
66 SET_TESTS_PROPERTIES(zorba_data-converters_module/converters/jansson/parse_json_03.xq
67 PROPERTIES WILL_FAIL TRUE)
68 ENDIF(ZORBA_NO_UNICODE)
69
70 ELSE (Jansson_FOUND)
71 MESSAGE (STATUS "Jansson library not found -- if you want to use Json functionality please set Jansson_INCLUDE_DIRS and Jansson_LIBRARIES cmake parameters.")
72 ENDIF (Jansson_FOUND)
73ENDIF (ZORBA_SUPPRESS_JANSSON)
74MESSAGE (STATUS "")
75
76
77# csv43# csv
78DECLARE_ZORBA_SCHEMA (FILE csv-options.xsd44DECLARE_ZORBA_SCHEMA (FILE csv-options.xsd
79 URI "http://www.zorba-xquery.com/modules/converters/csv-options")45 URI "http://www.zorba-xquery.com/modules/converters/csv-options")
@@ -97,4 +63,3 @@
97 SET_TESTS_PROPERTIES(zorba_data-converters_module/converters/csv/csv_parse_utf8_11.xq63 SET_TESTS_PROPERTIES(zorba_data-converters_module/converters/csv/csv_parse_utf8_11.xq
98 PROPERTIES WILL_FAIL TRUE)64 PROPERTIES WILL_FAIL TRUE)
99ENDIF(ZORBA_NO_UNICODE)65ENDIF(ZORBA_NO_UNICODE)
100
10166
=== removed file 'src/com/zorba-xquery/www/modules/converters/json-options.xsd'
--- src/com/zorba-xquery/www/modules/converters/json-options.xsd 2011-08-11 20:09:07 +0000
+++ src/com/zorba-xquery/www/modules/converters/json-options.xsd 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
1<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
2 xmlns:json="http://www.zorba-xquery.com/modules/converters/json-options"
3 targetNamespace="http://www.zorba-xquery.com/modules/converters/json-options"
4 elementFormDefault="qualified" attributeFormDefault="unqualified">
5<!--
6:: Copyright 2006-2008 The FLWOR Foundation.
7::
8:: Licensed under the Apache License, Version 2.0 (the "License");
9:: you may not use this file except in compliance with the License.
10:: You may obtain a copy of the License at
11::
12:: http://www.apache.org/licenses/LICENSE-2.0
13::
14:: Unless required by applicable law or agreed to in writing, software
15:: distributed under the License is distributed on an "AS IS" BASIS,
16:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17:: See the License for the specific language governing permissions and
18:: limitations under the License.
19::
20-->
21
22
23 <xs:element name="options">
24 <xs:complexType>
25 <xs:sequence>
26 <xs:element name="json-param" minOccurs="1" maxOccurs="1">
27 <xs:complexType>
28 <xs:simpleContent>
29 <xs:extension base="xs:string">
30 <xs:attribute name="name" type="xs:string" use="required"/>
31 <xs:attribute name="value" use="required">
32 <xs:simpleType>
33 <xs:restriction base="xs:string">
34 <xs:enumeration value="simple-json"/>
35 <xs:enumeration value="json-ml"/>
36 </xs:restriction>
37 </xs:simpleType>
38 </xs:attribute>
39 <xs:attribute name="type" type="xs:string" use="optional"/>
40 </xs:extension>
41 </xs:simpleContent>
42 </xs:complexType>
43 </xs:element>
44 </xs:sequence>
45 </xs:complexType>
46 </xs:element>
47</xs:schema>
480
=== removed file 'src/com/zorba-xquery/www/modules/converters/json.xq'
--- src/com/zorba-xquery/www/modules/converters/json.xq 2012-01-09 21:58:00 +0000
+++ src/com/zorba-xquery/www/modules/converters/json.xq 1970-01-01 00:00:00 +0000
@@ -1,242 +0,0 @@
1xquery version "3.0";
2
3 (:
4 : Copyright 2006-2009 The FLWOR Foundation.
5 :
6 : Licensed under the Apache License, Version 2.0 (the "License");
7 : you may not use this file except in compliance with the License.
8 : You may obtain a copy of the License at
9 :
10 : http://www.apache.org/licenses/LICENSE-2.0
11 :
12 : Unless required by applicable law or agreed to in writing, software
13 : distributed under the License is distributed on an "AS IS" BASIS,
14 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 : See the License for the specific language governing permissions and
16 : limitations under the License.
17 :)
18
19 (:~
20 :
21 : <p>In order to enable JSON processing with XQuery, Zorba implements a set
22 : of functions that open XQuery developers the door to process JSON
23 : data. Specifically, this module provides two types of functions. Functions
24 : to:
25 : <ul>
26 : <li>parse JSON and convert it to XDM and</li>
27 : <li>serialize XDM in order to output JSON.</li>
28 : </ul>
29 : </p>
30 :
31 : <p>Both types of functions are available to parse and serialize two
32 : types of XDM-JSON mappings:<ul><li>the first mapping called in this document
33 : <strong>simple XDM-JSON</strong> has been
34 : <a href="http://john.snelson.org.uk/parsing-json-into-xquery">
35 : proposed by John Snelson</a></li><li>the second mapping is called
36 : <a href="http://jsonml.org/">JsonML</a></li></ul>In the following, we
37 : briefly describe both mappings.</p>
38 :
39 : <h2>Simple XDM-JSON Mapping</h2>
40 : <ul><li>In order to process JSON with XQuery, Zorba implements a mapping between
41 : JSON and XML that was initially proposed by John Snelson in his article
42 : <a href="http://john.snelson.org.uk/parsing-json-into-xquery"
43 : target="_blank">Parsing JSON into XQuery</a></li></ul>
44 :
45 : <h2>JsonML Mapping</h2>
46 : <ul>
47 : <li><a href="http://jsonml.org" target="_blank">JSonML</a> (JSON Markup Language)
48 : is an application of the JSON format.</li>
49 : <li>The purpose of JSonML is to provide a compact format for transporting
50 : XML-based markup as JSon. In contrast to the <strong>simple XDM-JSON</strong> mapping described above
51 : <strong>JsonML</strong> allows a lossless conversion back and forth.</li></ul>
52 :
53 : <h2>Important Notes:</h2>
54 : <ul><li>Zorba uses the <a href="http://www.digip.org/jansson/">Jansson library</a>
55 : for manipulating JSON data.</li>
56 : <li>We have tested against the following Jansson library versions:
57 : <ul><li><a href="http://www.digip.org/jansson/doc/1.2/">Jansson 1.2.1</a></li>
58 : <li><a href="http://www.digip.org/jansson/doc/1.3/">Jansson 1.3</a></li>
59 : <li><a href="http://www.digip.org/jansson/doc/2.0/">Jansson 2.0</a></li></ul> available from
60 : <a href="http://www.digip.org/jansson/releases/">Jansson releases</a>.</li></ul>
61 :
62 : @author Sorin Nasoi
63 : @library <a href="http://www.digip.org/jansson/">Jansson library for encoding, decoding and manipulating JSON data</a>
64 :
65 : @see <a href="http://john.snelson.org.uk/parsing-json-into-xquery">Mapping proposed by John Snelson</a>
66 : @see <a href="http://jsonml.org" target="_blank">JSonML</a>
67 : @see <a href="http://www.digip.org/jansson/doc/2.0/">Jansson library for encoding, decoding and manipulating JSON data</a>
68 : @project data processing/data converters
69 :
70 :)
71module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
72
73import module namespace schema = "http://www.zorba-xquery.com/modules/schema";
74
75import schema namespace json-options = "http://www.zorba-xquery.com/modules/converters/json-options";
76
77declare namespace err = "http://www.w3.org/2005/xqt-errors";
78
79declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
80declare option ver:module-version "1.0";
81
82(:~
83 : This function parses a JSON string and returns an XDM instance according
84 : to either one of the mappings described above.
85 :
86 : @param $arg a sequence of valid JSON strings.
87 : @param $options a set of name and value pairs that provide options
88 : to configure the JSON mapping process that have to be validated against the
89 : "http://www.zorba-xquery.com/modules/converters/json-options" schema.
90 : @return a sequence of nodes according to either one of the mappings described above.
91 : @error err:XQDY0027 if $options can not be validated against the json-options schema
92 : @error json:ParseError if the JSON string passed as parameter is not
93 : valid JSON.
94 : @example test_json/Queries/converters/jansson/parse_json_02.xq
95 : @example test_json/Queries/converters/jansson/parse_json_ml_01.xq
96 :)
97declare function json:parse(
98 $arg as xs:string?,
99 $options as element(json-options:options)
100) as document-node(element(*, xs:untyped))
101{
102 let $validated-options := if(schema:is-validated($options)) then
103 $options
104 else
105 validate{$options}
106 return
107 json:parse-internal($arg, $validated-options)
108};
109
110(:~
111 : This function parses a JSON string and returns an XDM instance according
112 : to simple XDM-JSON mapping described above.
113 :
114 : @param $arg a sequence of valid JSON strings.
115 : @return a sequence of nodes according to Simple XDM-JSON mapping described above.
116 : @error json:ParseError if the JSON string passed as parameter is not
117 : valid JSON.
118 : @example test_json/Queries/converters/jansson/parse_json_11.xq
119 :)
120declare function json:parse(
121 $arg as xs:string?
122) as document-node(element(*, xs:untyped))
123{
124 json:parse-internal($arg,
125 validate {
126 <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
127 <json-param name="mapping" value="simple-json" />
128 </options>
129 }
130 )
131};
132
133(:~
134 : This function parses a JSON string and returns an XDM instance according
135 : to JsonML mapping described above.
136 :
137 : @param $arg a sequence of valid JSON strings.
138 : @return a sequence of nodes according the JSON-ML mapping described above.
139 : @error json:ParseError if the JSON string passed as parameter is not
140 : valid JSON.
141 : @example test_json/Queries/converters/jansson/parse_json_ml_05.xq
142 :)
143declare function json:parse-ml(
144 $arg as xs:string?
145) as document-node(element(*, xs:untyped))
146{
147 json:parse-internal($arg,
148 validate {
149 <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
150 <json-param name="mapping" value="json-ml" type="array"/>
151 </options>
152 }
153 )
154};
155
156declare %private function json:parse-internal(
157 $html as xs:string,
158 $options as element(json-options:options)?
159) as document-node(element(*, xs:untyped)) external;
160
161
162(:~
163 : The serialize function takes a sequence of nodes as parameter and
164 : transforms each element into a valid JSON string according to one of the
165 : mappings described above.
166 :
167 : @param $xml a sequence of nodes.
168 : @param $options a set of name and value pairs that provide options
169 : to configure the JSON mapping process that have to be validated against the
170 : "http://www.zorba-xquery.com/modules/converters/json-options" schema.
171 : @return a JSON string.
172 : @error err:XQDY0027 if $options can not be validated against the json-options schema
173 : @error json:InvalidXDM if the input $xml is not a valid XDM
174 : representation of JSON or JSON ML.
175 : @example test_json/Queries/converters/jansson/serialize_json_01.xq
176 : @example test_json/Queries/converters/jansson/serialize_json_ml_01.xq
177 :)
178declare function json:serialize(
179 $xml as item()*,
180 $options as element(json-options:options)
181) as xs:string
182{
183 let $validated-options := if(schema:is-validated($options)) then
184 $options
185 else
186 validate{$options}
187 return
188 json:serialize-internal($xml, $validated-options)
189};
190
191(:~
192 : The serialize function takes a sequence of nodes as parameter and
193 : transforms each element into a valid JSON string according to the
194 : Simple XDM-JSON mapping described above
195 :
196 : @param $xml a sequence of nodes.
197 : @return a JSON string.
198 : @error json:InvalidXDM if the input $xml is not a valid XDM
199 : representation of JSON or JSON ML.
200 : @example test_json/Queries/converters/jansson/serialize_json_18.xq
201 :)
202declare function json:serialize(
203 $xml as item()*
204) as xs:string
205{
206 json:serialize-internal($xml,
207 validate {
208 <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
209 <json-param name="mapping" value="simple-json" />
210 </options>
211 }
212 )
213};
214
215(:~
216 : The serialize function takes a sequence of nodes as parameter and
217 : transforms each element into a valid JSON string according to the
218 : JsonML mapping described above.
219 :
220 : @param $xml a sequence of nodes.
221 : @return a JSON string.
222 : @error json:InvalidXDM if the input $xml is not a valid XDM
223 : representation of JSON or JSON ML.
224 : @example test_json/Queries/converters/jansson/serialize_json_ml_04.xq
225 :)
226declare function json:serialize-ml(
227 $xml as item()*
228) as xs:string
229{
230 json:serialize-internal($xml,
231 validate {
232 <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
233 <json-param name="mapping" value="json-ml" type="array"/>
234 </options>
235 }
236 )
237};
238
239declare %private function json:serialize-internal(
240 $xml as item()*,
241 $options as element(json-options:options)?
242 ) as xs:string external;
2430
=== removed directory 'src/com/zorba-xquery/www/modules/converters/json.xq.src'
=== removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp'
--- src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp 2011-12-07 19:24:59 +0000
+++ src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp 1970-01-01 00:00:00 +0000
@@ -1,729 +0,0 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <sstream>
18#include <cstring>
19
20#include <zorba/zorba.h>
21#include <zorba/iterator.h>
22#include <zorba/store_consts.h>
23
24#include <jansson.h>
25
26#include "jansson_wrapper.h"
27
28namespace zorba
29{
30namespace jsonmodule
31{
32static void serialize_child(
33 const zorba::Item& aElement,
34 std::stringstream& aResultSs,
35 std::stringstream& aErrorLogSs,
36 const std::string& aParentType);
37
38bool replace_all( std::string &s, char from, char to ) {
39 bool replaced_any = false;
40 for ( std::string::size_type pos = 0; pos < s.size(); ++pos ) {
41 if ( (pos = s.find( from, pos )) == std::string::npos )
42 break;
43 s.replace( pos, 1, 1, to );
44 replaced_any = true;
45 }
46 return replaced_any;
47}
48
49bool replace_all( std::string &s,
50 char const *from, std::string::size_type from_len,
51 char const *to, std::string::size_type to_len ) {
52 bool replaced_any = false;
53 for ( std::string::size_type pos = 0;
54 pos + from_len <= s.size(); pos += to_len ) {
55 if ( (pos = s.find( from, pos, from_len )) == std::string::npos )
56 break;
57 s.replace( pos, from_len, to, to_len );
58 replaced_any = true;
59 }
60 return replaced_any;
61}
62
63bool replace_all( std::string &s, char const *from, char const *to )
64{
65 return replace_all( s, from, std::strlen( from ), to, std::strlen( to ) );
66}
67
68void replace_special_chars(
69 std::string &aValue)
70{
71 replace_all(aValue, "\"", "\\\"" ); //quotation mark
72 replace_all(aValue, "\\", "\\\\" ); //reverse solidus
73 replace_all(aValue, "/" , "\\/" ); //solidus
74 replace_all(aValue, "\b", "\\b" ); //backspace
75 replace_all(aValue, "\f", "\\f" ); //formfeed
76 replace_all(aValue, "\n", "\\n" ); //new line
77 replace_all(aValue, "\r", "\\r" ); //carriage return
78 replace_all(aValue, "\t", "\\t" ); //horizontal tab
79 replace_all(aValue, "<" , "&lt;" ); // <
80 replace_all(aValue, ">" , "&gt;" ); // >
81}
82
83static void parse_Json_value(
84 const char *aKey,
85 json_t *aValue,
86 const char* aParentType,
87 std::stringstream& aSs,
88 std::stringstream& aErrorLogSs)
89{
90 if(!aValue)
91 return;
92
93 switch(json_typeof(aValue))
94 {
95 case JSON_OBJECT:
96 {
97 const char *lKey;
98 json_t *lValue;
99 std::string lTmp(aKey);
100
101 //<pair name=\"[...]\" type=\"object\">[...]</pair>
102 aSs << "<pair";
103 if(!lTmp.empty())
104 aSs << " name=\"" << lTmp << "\"";
105 aSs << " type=\"object\">";
106
107 void *lIter = json_object_iter(aValue);
108 while(lIter)
109 {
110 lKey = json_object_iter_key(lIter);
111 lValue = json_object_iter_value(lIter);
112
113 parse_Json_value(lKey, lValue, "object", aSs, aErrorLogSs);
114
115 lIter = json_object_iter_next(aValue, lIter);
116 }
117
118 aSs << "</pair>";
119 break;
120 }
121 case JSON_ARRAY:
122 {
123 json_t *lValue;
124 zorba::String lName(aKey), lEmptyStr("");
125
126 //<pair name=\"[...]\" type=\"array\">[...]</pair>
127 aSs << "<pair name=\"" << lName << "\" type=\"array\">";
128
129 for(size_t i = 0; i < json_array_size(aValue); i++)
130 {
131 lValue = json_array_get(aValue, i);
132
133 parse_Json_value(lEmptyStr.c_str(), lValue, "array", aSs, aErrorLogSs);
134 }
135
136 aSs << "</pair>";
137 break;
138 }
139 default:
140 {
141 //only NULL does not have a value
142 bool lHaveVal = !(json_is_null(aValue));
143
144 std::string lType, lValue;
145 if(json_is_null(aValue))
146 {
147 lType = "null";
148 lValue = "null";
149 }
150 else if(json_is_string(aValue))
151 {
152 lType = "string";
153 lValue = json_string_value(aValue);
154 }
155 else if(json_is_number(aValue))
156 {
157 lType = "number";
158
159 //json_string_value works just for STRING items so we have to use
160 //json_number_value that returns a double
161 std::ostringstream lOss;
162 lOss << json_number_value(aValue);
163 lValue = lOss.str();
164 }
165 else if(json_is_boolean(aValue))
166 {
167 lType = "boolean";
168 lValue = json_is_true(aValue)?"true":"false";
169 }
170
171 zorba::String lName(aKey);
172 std::string lParent(aParentType);
173 std::string lItemName = (lParent.compare("object") == 0)?"pair":"item";
174
175
176 aSs << "<" << lItemName;
177 if(!lName.empty())
178 {
179 aSs <<" name=\"" << lName << "\"";
180 }
181 aSs << " type=\"" << lType;
182 if(lHaveVal)
183 {
184 replace_special_chars(lValue);
185 aSs << "\">" << lValue << "</" << lItemName << ">";
186 }
187 else
188 aSs << "\"/>";
189
190 break;
191 }
192 }
193}
194
195
196void JSON_parse(
197 const char* aJsonString,
198 std::stringstream& aSs,
199 std::stringstream& aErrorLogSs)
200{
201 json_error_t lerror;
202 json_t *ljson;
203
204 #if JANSSON_MAJOR_VERSION < 2
205 ljson = json_loads(aJsonString, &lerror);
206 #else
207 ljson = json_loads(aJsonString, 0, &lerror);
208 #endif
209
210 if(!ljson)
211 {
212 #if JANSSON_MAJOR_VERSION < 2
213 aErrorLogSs << "Error at line: " << lerror.line << std::endl;
214 aErrorLogSs << lerror.text << std::endl;
215 #else
216 aErrorLogSs << "Error at line: " << lerror.line << " column: " << lerror.column << " position: " << lerror.position << std::endl;
217 aErrorLogSs << lerror.text << std::endl;
218 #endif
219 return;
220 }
221
222 const char *lKey;
223 json_t *lValue;
224 lKey = json_object_iter_key(ljson);
225
226 if(json_is_object(ljson))
227 {
228 aSs << "<json type=\"object\">";
229 void *lIter = json_object_iter(ljson);
230 while(lIter)
231 {
232 lKey = json_object_iter_key(lIter);
233 lValue = json_object_iter_value(lIter);
234
235 parse_Json_value(lKey, lValue, "object", aSs, aErrorLogSs);
236
237 lIter = json_object_iter_next(ljson, lIter);
238 }
239 aSs << "</json>";
240 }
241 else if(json_is_array(ljson))
242 {
243 std::string lEmptyStr("");
244 aSs << "<json type=\"array\">";
245 for(size_t i = 0; i < json_array_size(ljson); i++)
246 {
247 lValue = json_array_get(ljson, i);
248
249 parse_Json_value(lEmptyStr.c_str(), lValue, "array", aSs, aErrorLogSs);
250 }
251 aSs << "</json>";
252 }
253 else
254 aErrorLogSs << "Either one of ARRAY and OBJECT are considered valid JSON." << std::endl;
255
256}
257
258void get_text_value(
259 const zorba::Item& aElement,
260 zorba::String& aValue)
261{
262 zorba::Iterator_t lChildrenIt;
263 zorba::Item lChild;
264
265 lChildrenIt = aElement.getChildren();
266 lChildrenIt->open();
267 while (lChildrenIt->next(lChild))
268 {
269 if (lChild.getNodeKind() == store::StoreConsts::textNode)
270 aValue = lChild.getStringValue();
271 }
272 lChildrenIt->close();
273}
274
275void serialize_element(
276 const zorba::Item& aElement,
277 std::stringstream& aResultSs,
278 std::stringstream& aErrorLogSs,
279 const std::string& aParentType)
280{
281 zorba::Iterator_t lAttrIt, lChildrenIt;
282 zorba::Item lAttr, lChild;
283 zorba::String lName, lType;
284
285 Item lNodeNameItem;
286 aElement.getNodeName(lNodeNameItem);
287
288 if(((aParentType.compare("object") == 0) &&
289 !(lNodeNameItem.getStringValue() == "pair" || lNodeNameItem.getStringValue() == "json")) ||
290 ((aParentType.compare("array") == 0) && lNodeNameItem.getStringValue() != "item"))
291 {
292 aErrorLogSs << "'Object' should have only 'pair' children and 'array' should have only 'item' children." << std::endl;
293 return;
294 }
295
296 lAttrIt = aElement.getAttributes();
297 lAttrIt->open();
298 while (lAttrIt->next(lAttr))
299 {
300 if(lAttr.getNodeKind() == store::StoreConsts::attributeNode)
301 {
302 Item lNodeNameItem;
303 lAttr.getNodeName(lNodeNameItem);
304 if(lNodeNameItem.getStringValue() == "type")
305 lType = lAttr.getStringValue();
306 else if(lNodeNameItem.getStringValue() == "name")
307 lName = lAttr.getStringValue();
308 }
309 }
310 lAttrIt->close();
311
312 if(lType.empty())
313 {
314 aErrorLogSs << "Element does not have a 'type' attribute defined." << std::endl;
315 return;
316 }
317
318 if(lType == "object")
319 {
320 if(!lName.empty())
321 aResultSs << "\"" << lName.c_str() << "\": ";
322
323 //serialize every children
324 aResultSs << "{";
325 serialize_child(aElement, aResultSs, aErrorLogSs, "object");
326 aResultSs << "}";
327 }
328 else if(lType == "array")
329 {
330 if(!lName.empty())
331 aResultSs << "\"" << lName.c_str() << "\": ";
332
333 //serialize every children
334 aResultSs << "[";
335 serialize_child(aElement, aResultSs, aErrorLogSs, "array");
336 aResultSs << "]";
337 }
338 else if(lType == "string")
339 {
340 zorba::String lValue;
341 get_text_value(aElement, lValue);
342 zorba::Item lNodeNameItem;
343 aElement.getNodeName(lNodeNameItem);
344 if(lNodeNameItem.getStringValue() == "pair")
345 {
346 if(lName.empty())
347 {
348 aErrorLogSs << "Element does not have a 'name' attribute defined." << std::endl;
349 return;
350 }
351 if(aParentType.compare("object") != 0)
352 {
353 aErrorLogSs << "'Pair' is allowed only as part of an object." << std::endl;
354 return;
355 }
356 aResultSs << "\"" << lName.c_str() << "\": ";
357 }
358 aResultSs << "\"" << lValue.c_str() << "\"";
359 }
360 else if(lType == "null")
361 {
362 zorba::Item lNodeNameItem;
363 aElement.getNodeName(lNodeNameItem);
364 if(lNodeNameItem.getStringValue() == "pair")
365 {
366 aResultSs << "\"" << lName.c_str() << "\": ";
367 }
368 aResultSs << "null";
369 }
370 else if(lType == "number" ||
371 lType == "boolean")
372 {
373 zorba::String lValue;
374 get_text_value(aElement, lValue);
375 zorba::Item lNodeNameItem;
376 aElement.getNodeName(lNodeNameItem);
377 if(lNodeNameItem.getStringValue() == "pair")
378 {
379 aResultSs << "\"" << lName.c_str() << "\": ";
380 }
381 aResultSs << lValue.c_str();
382 }
383 else
384 {
385 aErrorLogSs << "Type '" << lType.c_str() << "' not recognized." << std::endl;
386 return;
387 }
388}
389
390void serialize_child(
391 const zorba::Item& aElement,
392 std::stringstream& aResultSs,
393 std::stringstream& aErrorLogSs,
394 const std::string& aParentType)
395{
396 bool lFirst = true;
397 zorba::Iterator_t lChildrenIt;
398 zorba::Item lChild;
399
400 lChildrenIt = aElement.getChildren();
401 lChildrenIt->open();
402 while (lChildrenIt->next(lChild))
403 {
404 if(lChild.getNodeKind() == store::StoreConsts::elementNode)
405 {
406 if(!lFirst)
407 aResultSs << ", ";
408
409 serialize_element(lChild, aResultSs, aErrorLogSs, aParentType);
410 lFirst = false;
411 }
412 }
413 lChildrenIt->close();
414}
415
416void JSON_serialize(
417 const zorba::Item& aElement,
418 std::stringstream& aResultSs,
419 std::stringstream& aErrorLogSs)
420{
421 if (aElement.isNull())
422 {
423 aErrorLogSs << "Passed a NULL element to the JSON serializer." << std::endl;
424 return;
425 }
426
427 if(!(aElement.getNodeKind() == store::StoreConsts::documentNode ||
428 aElement.getNodeKind() == store::StoreConsts::elementNode))
429 {
430 aErrorLogSs << "Passed an incorrect Item to the JSON serializer." << std::endl;
431 return;
432 }
433
434 Item lNodeNameItem;
435 aElement.getNodeName(lNodeNameItem);
436
437 if(!lNodeNameItem.isNull() && lNodeNameItem.getStringValue() != "json")
438 {
439 aErrorLogSs << "This is not a JSON element." << std::endl;
440 return;
441 }
442
443 if(aElement.getNodeKind() == store::StoreConsts::documentNode)
444 {
445 serialize_child(aElement, aResultSs, aErrorLogSs, "object");
446 return;
447 }
448
449 zorba::Iterator_t lAttrIt;
450 zorba::Item lAttr;
451 zorba::String lType;
452 lAttrIt = aElement.getAttributes();
453 lAttrIt->open();
454 while (lAttrIt->next(lAttr))
455 {
456 if(lAttr.getNodeKind() == store::StoreConsts::attributeNode)
457 {
458 Item lNodeNameItem;
459 lAttr.getNodeName(lNodeNameItem);
460 if(lNodeNameItem.getStringValue() == "type")
461 lType = lAttr.getStringValue();
462 else
463 {
464 aErrorLogSs << "Could not retrieve the type of the Json root." << std::endl;
465 return;
466 }
467 }
468 }
469 lAttrIt->close();
470
471
472 if(lType == "object")
473 aResultSs << "{";
474 else
475 aResultSs << "[";
476
477 serialize_child(aElement, aResultSs, aErrorLogSs, "object");
478
479 if(lType == "object")
480 aResultSs << "}";
481 else
482 aResultSs << "]";
483}
484
485static void parse_JSON_ML_value(
486 const char *aKey,
487 json_t *aValue,
488 const char* aParentType,
489 std::stringstream& aSs,
490 std::stringstream& aErrorLogSs,
491 bool aShouldClose = false)
492{
493 if(!aValue)
494 return;
495
496 switch(json_typeof(aValue))
497 {
498 case JSON_OBJECT:
499 {
500 const char *lKey;
501 json_t *lValue;
502 std::string lTmp(aKey);
503
504 void *lIter = json_object_iter(aValue);
505 while(lIter)
506 {
507 lKey = json_object_iter_key(lIter);
508 lValue = json_object_iter_value(lIter);
509
510 parse_JSON_ML_value(lKey, lValue, "object", aSs, aErrorLogSs);
511
512 lIter = json_object_iter_next(aValue, lIter);
513 }
514 aSs << ">";
515 break;
516 }
517 case JSON_ARRAY:
518 {
519 json_t *lValue;
520 zorba::String lName(""), lEmptyStr("");
521 bool lShouldClose = true;
522
523 std::string lParent(aParentType);
524 if(lParent.compare("array") == 0)
525 {
526 for(size_t i = 0; i < json_array_size(aValue); i++)
527 {
528 lValue = json_array_get(aValue, i);
529
530 if(json_is_object(lValue))
531 lShouldClose = false;
532 }
533
534 aSs << "<";
535 }
536
537 std::string lTmp;
538 for(size_t i = 0; i < json_array_size(aValue); i++)
539 {
540 lValue = json_array_get(aValue, i);
541
542 parse_JSON_ML_value(lEmptyStr.c_str(), lValue, "array", aSs, aErrorLogSs, lShouldClose);
543
544 if(lShouldClose)
545 lShouldClose = false;
546 }
547
548 lValue = json_array_get(aValue, 0);
549 if(json_is_string(lValue))
550 lName = json_string_value(lValue);
551
552 if(lParent.compare("array") == 0)
553 aSs << "</" << lName << ">";
554
555 break;
556 }
557 default:
558 {
559 std::string lType, lValue;
560 if(json_is_string(aValue))
561 {
562 lType = "string";
563 lValue = json_string_value(aValue);
564 }
565 else if(json_is_boolean(aValue))
566 {
567 lType = json_is_true(aValue)?"true":"false";
568 lValue = lType;
569 }
570 else if(json_is_number(aValue))
571 {
572 lType = "number";
573
574 //json_string_value works just for STRING items so we have to use
575 //json_number_value that returns a double
576 std::ostringstream lOss;
577 lOss << json_number_value(aValue);
578 lValue = lOss.str();
579 }
580 else if(json_is_null(aValue))
581 {
582 lType = lValue = "null";
583 }
584
585 zorba::String lName(aKey);
586 std::string lParent(aParentType);
587
588 if(lParent.compare("array") == 0)
589 aSs << lValue;
590 else if(lParent.compare("object") == 0)
591 {
592 aSs << " " << lName << "=";
593 replace_special_chars(lValue);
594 if(lType.compare("string") == 0)
595 aSs << "\"" << lValue << "\"";
596 else
597 aSs << lValue;
598 }
599
600 if(aShouldClose)
601 aSs << ">";
602
603 break;
604 }
605 }
606}
607
608void JSON_ML_parse(
609 const char* aJsonString,
610 std::stringstream& aSs,
611 std::stringstream& aErrorLogSs)
612{
613 json_error_t lerror;
614 json_t *ljson;
615 zorba::String lEmptyStr("");
616
617 #if JANSSON_MAJOR_VERSION < 2
618 ljson = json_loads(aJsonString, &lerror);
619 #else
620 ljson = json_loads(aJsonString, 0, &lerror);
621 #endif
622 if(!ljson)
623 {
624 #if JANSSON_MAJOR_VERSION < 2
625 aErrorLogSs << "Error at line: " << lerror.line << std::endl;
626 aErrorLogSs << lerror.text << std::endl;
627 #else
628 aErrorLogSs << "Error at line: " << lerror.line << " column: " << lerror.column << " position: " << lerror.position << std::endl;
629 aErrorLogSs << lerror.text << std::endl;
630 #endif
631 return;
632 }
633
634 if(!json_is_array(ljson))
635 aErrorLogSs << "ARRAY is the only accepted root for the Json-ML mapping." << std::endl;
636
637 parse_JSON_ML_value(lEmptyStr.c_str(), ljson, "array", aSs, aErrorLogSs);
638}
639
640void JSON_ML_serialize(
641 const zorba::Item& aElement,
642 std::stringstream& aResultSs,
643 std::stringstream& aErrorLogSs)
644{
645 if (aElement.isNull())
646 {
647 aErrorLogSs << "Passed a NULL element to the JSON serializer." << std::endl;
648 return;
649 }
650
651 if(!(aElement.getNodeKind() == store::StoreConsts::documentNode ||
652 aElement.getNodeKind() == store::StoreConsts::elementNode ||
653 aElement.getNodeKind() == store::StoreConsts::textNode))
654 {
655 aErrorLogSs << "Passed an incorrect Item to the JSON serializer." << std::endl;
656 return;
657 }
658
659 if(aElement.getNodeKind() == store::StoreConsts::textNode)
660 {
661 aResultSs << "\"" << aElement.getStringValue().c_str() << "\"";
662 return;
663 }
664
665 Item lNodeNameItem;
666 aElement.getNodeName(lNodeNameItem);
667
668 aResultSs << "[\"" << lNodeNameItem.getStringValue().c_str() << "\"";
669
670 zorba::Iterator_t lAttrIt;
671 zorba::Item lAttr;
672 zorba::String lType;
673 bool lHasAttributes = false;
674
675 lAttrIt = aElement.getAttributes();
676 lAttrIt->open();
677 while (lAttrIt->next(lAttr))
678 {
679 if(lAttr.getNodeKind() == store::StoreConsts::attributeNode)
680 {
681 lHasAttributes = true;
682 break;
683 }
684 }
685 lAttrIt->close();
686
687 if(lHasAttributes)
688 aResultSs << ",{";
689
690 bool lFirst = true;
691 lAttrIt = aElement.getAttributes();
692 lAttrIt->open();
693 while (lAttrIt->next(lAttr))
694 {
695 if(lAttr.getNodeKind() == store::StoreConsts::attributeNode)
696 {
697 Item lNodeNameItem;
698 lAttr.getNodeName(lNodeNameItem);
699 if(!lFirst)
700 aResultSs << ",";
701
702 aResultSs << "\"" << lNodeNameItem.getStringValue().c_str() << "\":";
703 aResultSs << "\"" << lAttr.getStringValue().c_str() << "\"";
704 lFirst = false;
705 }
706 }
707 lAttrIt->close();
708 if(lHasAttributes)
709 aResultSs << "}";
710
711 zorba::Iterator_t lChildrenIt;
712 zorba::Item lChild;
713
714 lChildrenIt = aElement.getChildren();
715 lChildrenIt->open();
716 while (lChildrenIt->next(lChild))
717 {
718 aResultSs << ",";
719 if (lChild.getNodeKind() == store::StoreConsts::elementNode ||
720 lChild.getNodeKind() == store::StoreConsts::textNode)
721 JSON_ML_serialize(lChild, aResultSs, aErrorLogSs);
722 }
723 lChildrenIt->close();
724
725 aResultSs << "]";
726}
727
728 } /* namespace jsonmodule */
729} /* namespace zorba */
7300
=== removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.h'
--- src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.h 2011-10-06 07:40:17 +0000
+++ src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.h 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ZORBA_JSONMODULE_JANSSON_WRAPPER_H
18#define ZORBA_JSONMODULE_JANSSON_WRAPPER_H
19
20#include <zorba/item_factory.h>
21#include <zorba/item.h>
22
23namespace zorba
24{
25 namespace jsonmodule
26 {
27 //Json parse and serialize: http://www.json.org/
28 //according to the mapping proposed by john snelson:
29 //http://snelson.org.uk/archives/2008/02/parsing_json_in.php#more
30 void JSON_parse(
31 const char* aJsonString,
32 std::stringstream& aSs,
33 std::stringstream& aErrorLogSs);
34
35 void JSON_serialize(
36 const zorba::Item& aElement,
37 std::stringstream& aResultSs,
38 std::stringstream& aErrorLogSs);
39
40
41 //Json ML parse and serialize: http://jsonml.org/
42 void JSON_ML_parse(
43 const char* aJsonString,
44 std::stringstream& aSs,
45 std::stringstream& aErrorLogSs);
46
47
48 void JSON_ML_serialize(
49 const zorba::Item& aElement,
50 std::stringstream& aResultSs,
51 std::stringstream& aErrorLogSs);
52
53 } /* namespace jsonmodule */
54} /* namespace zorba */
55
56#endif //ZORBA_JSONMODULE_JANSSON_WRAPPER_H
57\ No newline at end of file0\ No newline at end of file
581
=== removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/json.cpp'
--- src/com/zorba-xquery/www/modules/converters/json.xq.src/json.cpp 2011-08-18 22:09:48 +0000
+++ src/com/zorba-xquery/www/modules/converters/json.xq.src/json.cpp 1970-01-01 00:00:00 +0000
@@ -1,317 +0,0 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <sstream>
18#include <cassert>
19
20#include <zorba/empty_sequence.h>
21#include <zorba/singleton_item_sequence.h>
22#include <zorba/diagnostic_list.h>
23#include <zorba/user_exception.h>
24#include <zorba/item.h>
25#include <zorba/store_consts.h>
26
27#include "json.h"
28#include "jansson_wrapper.h"
29
30namespace zorba
31{
32 namespace jsonmodule
33 {
34zorba::String
35JsonFunction::getOptionValue(zorba::Item& aOptionsItem, const char* aOptionName) const
36{
37 zorba::Iterator_t lChildrenIt, lAttrIt;
38 zorba::Item lChild, lAttr, lNodeNameItem;
39 bool lCorrectChild = false;
40
41 lChildrenIt = aOptionsItem.getChildren();
42 lChildrenIt->open();
43 while (lChildrenIt->next(lChild))
44 {
45 if (lChild.getNodeKind() == store::StoreConsts::elementNode)
46 {
47 lAttrIt = lChild.getAttributes();
48 lAttrIt->open();
49 while (lAttrIt->next(lAttr))
50 {
51 if(lAttr.getNodeKind() == store::StoreConsts::attributeNode)
52 {
53 lAttr.getNodeName(lNodeNameItem);
54 if(!lCorrectChild &&
55 lNodeNameItem.getStringValue() == "name")
56 lCorrectChild = lAttr.getStringValue() == "mapping";
57 else if(lCorrectChild &&
58 lNodeNameItem.getStringValue() == "value")
59 return lAttr.getStringValue();
60 }
61 }
62 }
63 }
64 lChildrenIt->close();
65
66 return zorba::String("");
67}
68//*****************************************************************************
69//*****************************************************************************
70
71ParseFunction::ParseFunction(const JsonModule* aModule)
72: JsonFunction(aModule)
73{
74}
75
76ItemSequence_t
77ParseFunction::evaluate(
78 const ExternalFunction::Arguments_t& aArgs,
79 const StaticContext* aSctxCtx,
80 const DynamicContext* aDynCtx) const
81 {
82 zorba::Item lStringItem, lOptionsItem, lResItem;
83 zorba::String lBaseUri, lJsonMapping, lOptionName("mapping");
84 std::stringstream lSs, lErrorLogSs;
85
86 if (aArgs.size() >= 1)
87 {
88 Iterator_t lArg0Iter = aArgs[0]->getIterator();
89 lArg0Iter->open();
90 lArg0Iter->next(lStringItem);
91 lArg0Iter->close();
92 }
93
94 lBaseUri = aSctxCtx->getBaseURI();
95
96 if (aArgs.size() == 2)
97 {
98 Iterator_t lArg0Iter = aArgs[1]->getIterator();
99 lArg0Iter->open();
100 lArg0Iter->next(lOptionsItem);
101 lArg0Iter->close();
102 }
103
104 lJsonMapping = getOptionValue(lOptionsItem, lOptionName.c_str());
105
106 if(lJsonMapping == "simple-json")
107 {
108 JSON_parse(lStringItem.getStringValue().c_str(), lSs, lErrorLogSs);
109 }
110 else // if(lJsonMapping == "json-ml")
111 {
112 assert(lJsonMapping == "json-ml"); // the schema makes sure that this is the case
113 JSON_ML_parse(lStringItem.getStringValue().c_str(), lSs, lErrorLogSs);
114 }
115
116 if(!lErrorLogSs.str().empty())
117 {
118 zorba::Item lError = theModule->getItemFactory()->createQName(theModule->getURI(), "ParseError");
119 throw USER_EXCEPTION(lError, lErrorLogSs.str());
120 }
121
122 XmlDataManager* lDataManager = Zorba::getInstance(0)->getXmlDataManager();
123 Item lItem = lDataManager->parseXML(lSs);
124
125 return ItemSequence_t(new SingletonItemSequence(lItem));
126 }
127
128//*****************************************************************************
129//*****************************************************************************
130SerializeFunction::StringStreamSequence::StringStreamSequence(ItemSequence* input)
131 : input_iter(input->getIterator()),
132 is(new std::istream(this))
133{
134 line_index = 0;
135 has_next = true;
136 is_open = false;
137 open_count = 0;
138 input_iter->open();
139}
140
141void SerializeFunction::StringStreamSequence::open()
142{
143 is_open = true;
144 line_index = 1;
145 if(open_count)
146 {
147 is->seekg(0);
148 if(is->fail())
149 throw USER_EXCEPTION(theFactory->createQName(
150 "http://www.zorba-xquery.com/modules/converters/json",
151 "InvalidStream"),
152 "Cannot reset streamable string item");
153 }
154 open_count++;
155}
156
157void SerializeFunction::StringStreamSequence::close()
158{
159 is_open = false;
160}
161
162bool SerializeFunction::StringStreamSequence::isOpen() const
163{
164 return is_open;
165}
166
167bool SerializeFunction::StringStreamSequence::next( Item &result )
168{
169 assert(is_open);
170
171 if(!has_next)
172 return false;
173 result = streamable_item;
174 has_next = false;
175 return true;
176}
177
178bool SerializeFunction::StringStreamSequence::next(std::string &result_string)
179{
180 if(!input_iter->next(node_item))
181 return false;
182
183 std::stringstream lSs, lErrorLogSs;
184
185 if(theMapping == "simple-json")
186 JSON_serialize(node_item, lSs, lErrorLogSs);
187 else if(theMapping == "json-ml")
188 JSON_ML_serialize(node_item, lSs, lErrorLogSs);
189
190 if(!lErrorLogSs.str().empty())
191 {
192 throw USER_EXCEPTION(
193 theFactory->createQName(
194 "http://www.zorba-xquery.com/modules/converters/json",
195 "InvalidXDM"),
196 lErrorLogSs.str());
197 }
198
199 result_string = lSs.str();
200 return true;
201}
202
203bool SerializeFunction::StringStreamSequence::reset()
204{
205 input_iter->close();
206 input_iter->open();
207 return true;
208}
209
210
211SerializeFunction::SerializeFunction(const JsonModule* aModule)
212: JsonFunction(aModule)
213{
214}
215
216ItemSequence_t
217SerializeFunction::evaluate(
218 const ExternalFunction::Arguments_t& aArgs,
219 const StaticContext* aSctxCtx,
220 const DynamicContext* aDynCtx) const
221 {
222 zorba::Item lOptionsItem, lResItem;
223 zorba::String lBaseUri, lJsonMapping, lOptionName("mapping");
224 std::stringstream lSs, lErrorLogSs;
225
226 lBaseUri = aSctxCtx->getBaseURI();
227
228 if (aArgs.size() == 2)
229 {
230 Iterator_t lArg0Iter = aArgs[1]->getIterator();
231 lArg0Iter->open();
232 lArg0Iter->next(lOptionsItem);
233 lArg0Iter->close();
234 }
235
236 lJsonMapping = getOptionValue(lOptionsItem, lOptionName.c_str());
237
238 if(lJsonMapping != "simple-json" &&
239 lJsonMapping != "json-ml")
240 {
241 zorba::Item lError = theModule->getItemFactory()->createQName(theModule->getURI(), "WrongParam");
242 lErrorLogSs << "Mapping type '" << lJsonMapping << "' not supported.\nPossible values are 'simple-json' or 'json-ml'.";
243 throw USER_EXCEPTION(lError, lErrorLogSs.str());
244 }
245
246 StringStreamSequence *stream_sequence = new StringStreamSequence((ItemSequence*)aArgs[0]);
247 stream_sequence->theMapping = lJsonMapping;
248 stream_sequence->theFactory = theModule->getItemFactory();
249 stream_sequence->streamable_item =
250 theModule->getItemFactory()->createStreamableString(
251 *(stream_sequence->is), &StringStreamSequence::releaseStream);
252
253 return ItemSequence_t(stream_sequence);
254
255 }
256
257//*****************************************************************************
258//*****************************************************************************
259
260ItemFactory* JsonModule::theFactory = 0;
261
262JsonModule::~JsonModule()
263{
264 for ( FuncMap_t::const_iterator lIter = theFunctions.begin();
265 lIter != theFunctions.end();
266 ++lIter)
267 {
268 delete lIter->second;
269 }
270 theFunctions.clear();
271}
272
273ExternalFunction*
274JsonModule::getExternalFunction(const String& aLocalname)
275{
276 ExternalFunction*& lFunc = theFunctions[aLocalname];
277 if (!lFunc)
278 {
279 if (1 == 0)
280 { }
281 else if (aLocalname == "parse-internal")
282 {
283 lFunc = new ParseFunction(this);
284 }
285 else if (aLocalname == "serialize-internal")
286 {
287 lFunc = new SerializeFunction(this);
288 }
289 }
290 return lFunc;
291}
292
293void
294JsonModule::destroy()
295{
296 if (!dynamic_cast<JsonModule*>(this))
297 {
298 return;
299 }
300 delete this;
301}
302//*****************************************************************************
303//*****************************************************************************
304
305 } /* namespace jsonmodule */
306} /* namespace zorba */
307
308#ifdef WIN32
309# define DLL_EXPORT __declspec(dllexport)
310#else
311# define DLL_EXPORT __attribute__ ((visibility("default")))
312#endif
313
314extern "C" DLL_EXPORT zorba::ExternalModule* createModule()
315{
316 return new zorba::jsonmodule::JsonModule();
317}
3180
=== removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/json.h'
--- src/com/zorba-xquery/www/modules/converters/json.xq.src/json.h 2011-10-06 07:40:17 +0000
+++ src/com/zorba-xquery/www/modules/converters/json.xq.src/json.h 1970-01-01 00:00:00 +0000
@@ -1,167 +0,0 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef ZORBA_JSONMODULE_JSON_H
17#define ZORBA_JSONMODULE_JSON_H
18
19#include <map>
20
21#include <zorba/zorba.h>
22#include <zorba/iterator.h>
23#include <zorba/function.h>
24#include <zorba/external_module.h>
25
26#include "stringiterator_streambuf.h"
27
28namespace zorba
29{
30 namespace jsonmodule
31 {
32//*****************************************************************************
33//*****************************************************************************
34 class JsonModule : public ExternalModule
35 {
36 private:
37 static ItemFactory* theFactory;
38
39 protected:
40 class ltstr
41 {
42 public:
43 bool operator()(const String& s1, const String& s2) const
44 {
45 return s1.compare(s2) < 0;
46 }
47 };
48
49 typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t;
50
51 FuncMap_t theFunctions;
52
53 public:
54 virtual ~JsonModule();
55
56 virtual String
57 getURI() const { return "http://www.zorba-xquery.com/modules/converters/json"; }
58
59 virtual ExternalFunction*
60 getExternalFunction(const String& aLocalname);
61
62 virtual void
63 destroy();
64
65 static ItemFactory*
66 getItemFactory()
67 {
68 if(!theFactory)
69 {
70 theFactory = Zorba::getInstance(0)->getItemFactory();
71 }
72 return theFactory;
73 }
74 };
75
76//*****************************************************************************
77//*****************************************************************************
78 class JsonFunction : public ContextualExternalFunction
79 {
80 protected:
81 const JsonModule* theModule;
82 zorba::String getOptionValue(zorba::Item& aOptionsItem, const char* aOptionName) const;
83 public:
84 JsonFunction(const JsonModule* aModule)
85 : theModule(aModule) {};
86
87 ~JsonFunction() {};
88
89 virtual String
90 getURI() const { return theModule->getURI(); }
91
92 };
93
94//*****************************************************************************
95//*****************************************************************************
96 class ParseFunction : public JsonFunction
97 {
98 public:
99 ParseFunction(const JsonModule* aModule);
100
101 virtual String
102 getLocalName() const { return "parse-internal"; }
103
104 virtual ItemSequence_t
105 evaluate(const ExternalFunction::Arguments_t& args,
106 const StaticContext* aSctxCtx,
107 const DynamicContext* aDynCtx) const;
108 };
109
110 class SerializeFunction : public JsonFunction
111 {
112 class StringStreamSequence : public ItemSequence, public Iterator, public StringIteratorStreamBuf
113 {
114 private:
115 Iterator_t input_iter;
116 std::vector<std::vector<String> > headers;
117 int line_index;
118 bool has_next;
119 bool is_open;
120 int open_count;
121
122 std::vector<String> line;
123 Item node_item;
124 public:
125 std::istream* is;
126 String theMapping;
127 ItemFactory* theFactory;
128 Item streamable_item;
129 public:
130 StringStreamSequence(ItemSequence* input);
131 virtual ~StringStreamSequence() {}
132
133 //for Iterator
134 virtual void open();
135 virtual void close();
136 virtual bool isOpen() const;
137 virtual bool next( Item &result );
138
139 //for ItemSequence
140 Iterator_t getIterator() {return this;}
141
142 //for StringIteratorStreamBuf
143 virtual bool next(std::string &next_string);
144 virtual bool reset();
145
146 static void
147 releaseStream(std::istream* stream) { delete stream; }
148
149 };
150 public:
151 SerializeFunction(const JsonModule* aModule);
152
153 virtual String
154 getLocalName() const { return "serialize-internal"; }
155
156 virtual ItemSequence_t
157 evaluate(const ExternalFunction::Arguments_t& args,
158 const StaticContext* aSctxCtx,
159 const DynamicContext* aDynCtx) const;
160 };
161
162
163
164 } /* namespace jsonmodule */
165} /* namespace zorba */
166
167#endif /* ZORBA_JSONMODULE_JSON_H */
1680
=== removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.cpp'
--- src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.cpp 2011-07-13 01:57:10 +0000
+++ src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.cpp 1970-01-01 00:00:00 +0000
@@ -1,153 +0,0 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <zorba/diagnostic_list.h>
18
19#include "stringiterator_streambuf.h"
20
21using namespace std;
22namespace zorba{
23
24StringIteratorStreamBuf::StringIteratorStreamBuf()
25{
26 current_buffer = 0;
27 last_buffer = 0;
28 begin_offset = 0;
29 is_eof = false;
30}
31
32//get next buffer
33int StringIteratorStreamBuf::underflow()
34{
35 if(is_eof)
36 return EOF;
37
38 begin_offset += buffer[current_buffer].length();
39 current_buffer = 1 - current_buffer;
40 if(last_buffer != current_buffer)
41 {
42 buffer[current_buffer].resize(0);
43 last_buffer = current_buffer;
44 if(!next(buffer[current_buffer]))
45 {
46 //current_buffer = 1 - current_buffer;
47 buffer[current_buffer].resize(0);
48 is_eof = true;
49 return EOF;
50 }
51 }
52
53 char *buffstr = (char*)buffer[current_buffer].c_str();
54 setg(buffstr, buffstr, buffstr+buffer[current_buffer].length());
55 return *buffstr;
56}
57
58//unget char, some special cases
59int StringIteratorStreamBuf::pbackfail ( int c )
60{
61 if(eback() != gptr())
62 {
63 setg(eback(), gptr()-1, egptr());
64 if(c != EOF)
65 *gptr() = (char)c;
66 return 1;
67 }
68
69 //else have to rewind to previous buffer
70 if(last_buffer != current_buffer)
71 return EOF;
72 if(buffer[1-last_buffer].length() == 0)
73 return EOF;
74 current_buffer = 1 - current_buffer;
75
76 begin_offset -= buffer[current_buffer].length();
77 char *buffstr = (char*)buffer[current_buffer].c_str();
78 setg(buffstr, buffstr+buffer[current_buffer].length()-1, buffstr+buffer[current_buffer].length());
79 if(c != EOF)
80 *gptr() = (char)c;
81 return 1;
82}
83
84//set a new position
85//if going too much back, restart the iterator
86streampos StringIteratorStreamBuf::seekoff ( streamoff off, ios_base::seekdir way, ios_base::openmode which )
87{
88 if(!(which & ios_base::in))
89 return -1;
90
91 streampos targetpos;
92 if(way == ios_base::end)
93 {
94 if(off > 0)
95 return -1;
96 while(underflow() != EOF);
97 streampos maxpos = begin_offset + (streamoff)buffer[current_buffer].length();
98 targetpos = maxpos + off;
99 }
100 else if(way == ios_base::cur)
101 {
102 targetpos = begin_offset + (streamoff)(gptr() - eback()) + off;
103 }
104 else if(way == ios_base::beg)
105 {
106 if(off < 0)
107 return -1;
108 targetpos = off;
109 }
110 else
111 return -1;
112 return seekpos(targetpos, ios_base::in);
113}
114
115//set a new position
116//if going too much back, restart the iterator
117streampos StringIteratorStreamBuf::seekpos ( streampos sp, ios_base::openmode which )
118{
119 if(!(which & ios_base::in))
120 return -1;
121
122 if(sp < begin_offset)
123 {
124 setg(eback(), eback(), egptr());
125 pbackfail(EOF);
126 if(sp < begin_offset)
127 {
128 //restart the iterator
129 if(!reset())
130 return -1;
131 buffer[0].resize(0);
132 buffer[1].resize(0);
133 current_buffer = last_buffer = 0;
134 begin_offset = 0;
135 is_eof = false;
136 setg(NULL, NULL, NULL);
137 }
138 }
139 while(sp >= (begin_offset+(streamoff)buffer[current_buffer].length()))
140 {
141 if(underflow() == EOF)
142 {
143 if(sp == (begin_offset+(streamoff)buffer[current_buffer].length()))
144 break;
145 return -1;
146 }
147 }
148
149 setg(eback(), eback() + (streamoff)(sp - begin_offset), egptr());
150 return sp;
151}
152
153}
1540
=== removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.h'
--- src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.h 2011-10-06 07:40:17 +0000
+++ src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.h 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdio.h>
18#include <streambuf>
19#include <istream>
20
21#ifndef STRING_ITERATOR_TO_STREAMBUF_IMPL
22#define STRING_ITERATOR_TO_STREAMBUF_IMPL
23
24namespace zorba{
25
26class StringIteratorStreamBuf : public std::streambuf
27{
28 std::string buffer[2];
29 int current_buffer;
30 int last_buffer;
31 std::streampos begin_offset;
32 bool is_eof;
33public:
34 StringIteratorStreamBuf();
35 virtual ~StringIteratorStreamBuf() {}
36
37 virtual int underflow ( );
38 virtual int pbackfail ( int c = EOF );
39
40 virtual std::streampos seekoff ( std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );
41 virtual std::streampos seekpos ( std::streampos sp, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );
42
43public:
44 virtual bool next(std::string &next_string) = 0;
45 virtual bool reset() = 0;
46};
47
48}
49#endif
500
=== removed directory 'test_json'
=== removed directory 'test_json/ExpQueryResults'
=== removed directory 'test_json/ExpQueryResults/converters'
=== removed directory 'test_json/ExpQueryResults/converters/jansson'
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_01.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_01.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_01.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_02.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_02.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_02.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="array"><pair type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></pair><pair type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_03.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_03.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_03.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="object"><pair name="mdash" type="string">–</pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_06.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_06.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_06.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="object"><pair name="web-app" type="string">!_\\"-\\?*.$+</pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_07.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_07.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_07.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="object"><pair name="special-numbers" type="object"><pair name="decimal" type="number">2.89</pair><pair name="e" type="number">2e+06</pair><pair name="negative" type="number">-1.89</pair></pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_08.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_08.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_08.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="object"><pair name="web-app" type="null"/></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_09.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_09.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_09.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="object"><pair name="bool" type="boolean">true</pair><pair name="numbers" type="array"><item type="number">1</item><item type="number">2</item><item type="number">3</item></pair><pair name="firstName" type="string">John</pair><pair name="state" type="null"/><pair name="address" type="object"><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="delivery" type="object"><pair name="streetAddress" type="string">StreetName</pair><pair name="city" type="string">CityName</pair><pair name="state" type="string">StateName</pair></pair><pair name="state" type="null"/><pair name="postalCode" type="number">10021</pair><pair name="literals" type="array"><item type="boolean">true</item><item type="boolean">false</item><item type="null"/></pair></pair><pair name="strings" type="array"><item type="string">one</item><item type="string">two</item><item type="string">three</item><item type="string">four</item></pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_10.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_10.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_10.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="array"><pair type="object"><pair name="lastName" type="string">Smith</pair><pair name="firstName" type="string">John</pair><pair name="address" type="object"><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="city" type="string">New York</pair><pair name="state" type="string">NY</pair><pair name="postalCode" type="number">10021</pair></pair><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair></pair><pair type="object"><pair name="bool" type="boolean">true</pair><pair name="numbers" type="array"><item type="number">1</item><item type="number">2</item><item type="number">3</item></pair><pair name="firstName" type="string">John</pair><pair name="state" type="null"/><pair name="address" type="object"><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="delivery" type="object"><pair name="streetAddress" type="string">StreetName</pair><pair name="city" type="string">CityName</pair><pair name="state" type="string">StateName</pair></pair><pair name="state" type="null"/><pair name="postalCode" type="number">10021</pair><pair name="literals" type="array"><item type="boolean">true</item><item type="boolean">false</item><item type="null"/></pair></pair><pair name="strings" type="array"><item type="string">one</item><item type="string">two</item><item type="string">three</item><item type="string">four</item></pair></pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_11.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_11.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_11.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<json type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></json>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res 2011-12-06 14:20:24 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"html": "&lt;b&gt;bold&lt;\/b&gt;"}
20
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_01.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_ml_01.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_01.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<ul><li style="color:red">First Item</li><li title="Some hover text." style="color:green">Second Item</li><li><span class="code-example-third">Third</span> Item</li></ul>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_02.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_ml_02.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_02.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<table class="MyTable" style="background-color:yellow"><tr><td class="MyTD" style="border:1px solid black">#550758</td><td class="MyTD" style="background-color:red">Example text here</td></tr><tr><td class="MyTD" style="border:1px solid black">#993101</td><td class="MyTD" style="background-color:green">127624015</td></tr><tr><td class="MyTD" style="border:1px solid black">#E33D87</td><td class="MyTD" style="background-color:blue"> <span style="background-color:maroon">©</span> </td></tr></table>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_05.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_ml_05.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_05.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<ul><li style="color:red">First Item</li><li title="Some hover text." style="color:green">Second Item</li><li><span class="code-example-third">Third</span> Item</li></ul>
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res'
--- test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res 2011-12-06 14:20:24 +0000
+++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1<html><b>bold</b></html>
20
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_01.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_01.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_01.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_02.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_02.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_02.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1[{"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}}, {"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}}]
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_04.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_04.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_04.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"firstName": "\""}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_05.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_05.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_05.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"name": "\"\\\/\b\f\n\r\t"}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_09.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_09.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_09.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"servlet": [["value1"], "value2"]}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_10.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_10.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_10.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"servlet": [{"name": "value1"}, "value2"]
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_13.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_13.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_13.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"servlet": ["value"]}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_14.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_14.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_14.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"servlet": {"name": "value"}}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_15.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_15.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_15.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"servlet": [{}]}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_16.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_16.xml.res 2011-12-07 18:44:46 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_16.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"servlet": [["212 732-1234"]]}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_17.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_17.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_17.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"special-chars": {"backslash": "\\", "formfeed": "\f", "quote": "\\"", "horizontal tab": "\t", "carriage return": "\r", "backspace": "\b", "newline": "\n", "solidus": "\/"}}
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_18.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_18.xml.res 2011-12-05 20:05:44 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_18.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1{"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}}
20
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_ml_01.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_ml_01.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_ml_01.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1["ul",["li",{"style":"color:red"},"First Item"],["li",{"title":"Some hover text.","style":"color:green"},"Second Item"],["li",["span",{"class":"code-example-third"},"Third"],"Item"]]
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_ml_02.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_ml_02.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_ml_02.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1["table",{"class":"MyTable","style":"background-color:yellow"},["tr",["td",{"class":"MyTD","style":"border:1px solid black"},"#5D28D1"],["td",{"class":"MyTD","style":"background-color:red"},"Example text here"]],["tr",["td",{"class":"MyTD","style":"border:1px solid black"},"#AF44EF"],["td",{"class":"MyTD","style":"background-color:green"},"127310656"]],["tr",["td",{"class":"MyTD","style":"border:1px solid black"},"#AAD034"],["td",{"class":"MyTD","style":"background-color:blue"},"\u00A0",["span",{"style":"background-color:maroon"},"\u00A9"],"\u00A0"]]]
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_ml_04.xml.res'
--- test_json/ExpQueryResults/converters/jansson/serialize_json_ml_04.xml.res 2011-05-31 15:21:09 +0000
+++ test_json/ExpQueryResults/converters/jansson/serialize_json_ml_04.xml.res 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1["ul",["li",{"style":"color:red"},"First Item"],["li",{"title":"Some hover text.","style":"color:green"},"Second Item"],["li",["span",{"class":"code-example-third"},"Third"],"Item"]]
2\ No newline at end of file0\ No newline at end of file
31
=== removed directory 'test_json/Queries'
=== removed directory 'test_json/Queries/converters'
=== removed directory 'test_json/Queries/converters/jansson'
=== removed file 'test_json/Queries/converters/jansson/parse_json_01.spec'
--- test_json/Queries/converters/jansson/parse_json_01.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/parse_json_01.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/parse_json_01.xq'
--- test_json/Queries/converters/jansson/parse_json_01.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_01.xq 1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
1(: the comparison method for this test is set to Ignore because the order in which the children
2are returned in jansson 1.2, 1.3, 2.0 is different:)
3
4import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
5import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
6
7json:parse(('{
8 "firstName": "John",
9 "lastName": "Smith",
10 "address": {
11 "streetAddress": "21 2nd Street",
12 "city": "New York",
13 "state": "NY",
14 "postalCode": 10021
15 },
16 "phoneNumbers": [
17 "212 732-1234",
18 "646 123-4567"
19 ]
20 }'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
21 <json-param name="mapping" value="simple-json" />
22 </options>)
230
=== removed file 'test_json/Queries/converters/jansson/parse_json_02.spec'
--- test_json/Queries/converters/jansson/parse_json_02.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/parse_json_02.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/parse_json_02.xq'
--- test_json/Queries/converters/jansson/parse_json_02.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_02.xq 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
1(: the comparison method for this test is set to Ignore because the order in which the children
2are returned in jansson 1.2, 1.3, 2.0 is different:)
3
4import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
5import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
6
7json:parse(('[
8{
9 "firstName": "John",
10 "lastName": "Smith",
11 "address": {
12 "streetAddress": "21 2nd Street",
13 "city": "New York",
14 "state": "NY",
15 "postalCode": 10021
16 },
17 "phoneNumbers": [
18 "212 732-1234",
19 "646 123-4567"
20 ]
21},
22{
23 "firstName": "John",
24 "lastName": "Smith",
25 "address": {
26 "streetAddress": "21 2nd Street",
27 "city": "New York",
28 "state": "NY",
29 "postalCode": 10021
30 },
31 "phoneNumbers": [
32 "212 732-1234",
33 "646 123-4567"
34 ]
35 }]'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
36 <json-param name="mapping" value="simple-json" />
37 </options>)
380
=== removed file 'test_json/Queries/converters/jansson/parse_json_03.xq'
--- test_json/Queries/converters/jansson/parse_json_03.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_03.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1(: try parsing a Unicode UTF-8 value :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:parse(('{"mdash": "–"}'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="simple-json" />
8 </options>)
9\ No newline at end of file0\ No newline at end of file
101
=== removed file 'test_json/Queries/converters/jansson/parse_json_04.spec'
--- test_json/Queries/converters/jansson/parse_json_04.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_04.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:ParseError
20
=== removed file 'test_json/Queries/converters/jansson/parse_json_04.xq'
--- test_json/Queries/converters/jansson/parse_json_04.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_04.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1(: try parsing an empty value :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:parse((<a/>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="simple-json" />
8 </options>)
9\ No newline at end of file0\ No newline at end of file
101
=== removed file 'test_json/Queries/converters/jansson/parse_json_05.spec'
--- test_json/Queries/converters/jansson/parse_json_05.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_05.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:ParseError
20
=== removed file 'test_json/Queries/converters/jansson/parse_json_05.xq'
--- test_json/Queries/converters/jansson/parse_json_05.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_05.xq 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4json:parse(('[ "ul",
5 [ "li",
6 true],
7 [ "li",
8 {"href":"driving.html", "title":"Driving"},
9 "Second item"],
10 [ "li", null],
11 [ "li", -14e12]
12'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
13 <json-param name="mapping" value="simple-json" />
14 </options>)
150
=== removed file 'test_json/Queries/converters/jansson/parse_json_06.xq'
--- test_json/Queries/converters/jansson/parse_json_06.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_06.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1(: json:parse with uncommon characters :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:parse('{ "web-app": "!_\"-\\?*.$+" }',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="simple-json" />
8 </options>)
90
=== removed file 'test_json/Queries/converters/jansson/parse_json_07.spec'
--- test_json/Queries/converters/jansson/parse_json_07.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/parse_json_07.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/parse_json_07.xq'
--- test_json/Queries/converters/jansson/parse_json_07.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_07.xq 1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
1(: json:parse testing numbers and decimals :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:parse('{ "special-numbers": {
7 "decimal": 2.89,
8 "e": 2E+6,
9 "negative": -1.89
10 }
11 }',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
12 <json-param name="mapping" value="simple-json" />
13 </options>)
140
=== removed file 'test_json/Queries/converters/jansson/parse_json_08.xq'
--- test_json/Queries/converters/jansson/parse_json_08.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_08.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1(: json:parse testing null handling :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:parse('{ "web-app": null }',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="simple-json" />
8 </options>)
90
=== removed file 'test_json/Queries/converters/jansson/parse_json_09.spec'
--- test_json/Queries/converters/jansson/parse_json_09.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/parse_json_09.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/parse_json_09.xq'
--- test_json/Queries/converters/jansson/parse_json_09.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_09.xq 1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4json:parse('{
5 "firstName": "John",
6 "state": null,
7 "bool": true ,
8 "numbers": [1,2,3] ,
9 "address": {
10 "streetAddress": "21 2nd Street",
11 "state": null,
12 "postalCode": 10021 ,
13 "literals": [true,false,null],
14 "delivery": {
15 "streetAddress": "StreetName",
16 "city": "CityName",
17 "state": "StateName"
18 }} ,
19 "strings": [
20 "one",
21 "two",
22 "three",
23 "four" ]
24}',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
25 <json-param name="mapping" value="simple-json" />
26 </options>)
270
=== removed file 'test_json/Queries/converters/jansson/parse_json_10.spec'
--- test_json/Queries/converters/jansson/parse_json_10.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/parse_json_10.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/parse_json_10.xq'
--- test_json/Queries/converters/jansson/parse_json_10.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_10.xq 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4json:parse('[{
5 "firstName": "John",
6 "lastName": "Smith",
7 "address": {
8 "streetAddress": "21 2nd Street",
9 "city": "New York",
10 "state": "NY",
11 "postalCode": 10021
12 },
13 "phoneNumbers": [
14 "212 732-1234",
15 "646 123-4567"
16 ]
17 },
18{
19 "firstName": "John",
20 "state": null,
21 "bool": true ,
22 "numbers": [1,2,3] ,
23 "address": {
24 "streetAddress": "21 2nd Street",
25 "state": null,
26 "postalCode": 10021 ,
27 "literals": [true,false,null],
28 "delivery": {
29 "streetAddress": "StreetName",
30 "city": "CityName",
31 "state": "StateName"
32 }} ,
33 "strings": [
34 "one",
35 "two",
36 "three",
37 "four" ]
38}]',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
39 <json-param name="mapping" value="simple-json" />
40 </options>)
410
=== removed file 'test_json/Queries/converters/jansson/parse_json_11.spec'
--- test_json/Queries/converters/jansson/parse_json_11.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/parse_json_11.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/parse_json_11.xq'
--- test_json/Queries/converters/jansson/parse_json_11.xq 2011-10-06 07:40:17 +0000
+++ test_json/Queries/converters/jansson/parse_json_11.xq 1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
1(: the comparison method for this test is set to Ignore because the order in which the children
2are returned in jansson 1.2, 1.3, 2.0 is different:)
3
4import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
5import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
6
7json:parse(('{
8 "firstName": "John",
9 "lastName": "Smith",
10 "address": {
11 "streetAddress": "21 2nd Street",
12 "city": "New York",
13 "state": "NY",
14 "postalCode": 10021
15 },
16 "phoneNumbers": [
17 "212 732-1234",
18 "646 123-4567"
19 ]
20 }'))
210
=== removed file 'test_json/Queries/converters/jansson/parse_json_12.xq'
--- test_json/Queries/converters/jansson/parse_json_12.xq 2011-12-06 14:20:24 +0000
+++ test_json/Queries/converters/jansson/parse_json_12.xq 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1import module namespace json="http://www.zorba-xquery.com/modules/converters/json";
2declare variable $json-value := '{"html":"<b>bold</b>"}';
3
4json:serialize(json:parse($json-value))
50
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_01.xq'
--- test_json/Queries/converters/jansson/parse_json_ml_01.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_01.xq 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4json:parse(('
5["ul",
6 ["li",
7 { "style" : "color:red" },
8 "First Item"
9 ],
10 ["li",
11 {
12 "title" : "Some hover text.",
13 "style" : "color:green"
14 },
15 "Second Item"
16 ],
17 ["li",
18 ["span",
19 { "class" : "code-example-third" },
20 "Third"
21 ],
22 " Item"
23 ]
24]'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options"
25 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
26 <json-param name="mapping" value="json-ml" type="array"/>
27 </options>)
28\ No newline at end of file0\ No newline at end of file
291
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_02.xq'
--- test_json/Queries/converters/jansson/parse_json_ml_02.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_02.xq 1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4json:parse(('
5["table",
6{
7"class" : "MyTable",
8"style" : "background-color:yellow"
9},
10["tr",
11["td",
12{
13"class" : "MyTD",
14"style" : "border:1px solid black"
15},
16"#550758"
17],
18["td",
19{
20"class" : "MyTD",
21"style" : "background-color:red"
22},
23"Example text here"
24]
25],
26["tr",
27["td",
28{
29"class" : "MyTD",
30"style" : "border:1px solid black"
31},
32"#993101"
33],
34["td",
35{
36"class" : "MyTD",
37"style" : "background-color:green"
38},
39"127624015"
40]
41],
42["tr",
43["td",
44{
45"class" : "MyTD",
46"style" : "border:1px solid black"
47},
48"#E33D87"
49],
50["td",
51{
52"class" : "MyTD",
53"style" : "background-color:blue"
54},
55"\u00A0",
56["span",
57{ "style" : "background-color:maroon" },
58"\u00A9"
59],
60"\u00A0"
61]
62]
63]'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
64 <json-param name="mapping" value="json-ml" type="array"/>
65 </options>)
660
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_03.spec'
--- test_json/Queries/converters/jansson/parse_json_ml_03.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_03.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:ParseError
20
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_03.xq'
--- test_json/Queries/converters/jansson/parse_json_ml_03.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_03.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1(: jsonml:parse with empty parameter :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:parse(<a/>,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="json-ml" type="array"/>
8 </options>)
90
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_04.spec'
--- test_json/Queries/converters/jansson/parse_json_ml_04.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_04.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:ParseError
20
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_04.xq'
--- test_json/Queries/converters/jansson/parse_json_ml_04.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_04.xq 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1(: jsonml:parse with invalid parameter :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:parse(('{
7 "firstName": "John",
8 "lastName": "Smith",
9 "address": {
10 "streetAddress": "21 2nd Street",
11 "city": "New York",
12 "state": "NY",
13 "postalCode": 10021
14 }'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
15 <json-param name="mapping" value="json-ml" type="array"/>
16 </options>)
170
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_05.xq'
--- test_json/Queries/converters/jansson/parse_json_ml_05.xq 2011-10-06 07:40:17 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_05.xq 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4json:parse-ml(('
5["ul",
6 ["li",
7 { "style" : "color:red" },
8 "First Item"
9 ],
10 ["li",
11 {
12 "title" : "Some hover text.",
13 "style" : "color:green"
14 },
15 "Second Item"
16 ],
17 ["li",
18 ["span",
19 { "class" : "code-example-third" },
20 "Third"
21 ],
22 " Item"
23 ]
24]'))
25\ No newline at end of file0\ No newline at end of file
261
=== removed file 'test_json/Queries/converters/jansson/parse_json_ml_06.xq'
--- test_json/Queries/converters/jansson/parse_json_ml_06.xq 2011-12-06 14:20:24 +0000
+++ test_json/Queries/converters/jansson/parse_json_ml_06.xq 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4json:parse('["html" ,"<b>bold</b>"]',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options"
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6 <json-param name="mapping" value="json-ml" type="array"/>
7 </options>)
80
=== removed file 'test_json/Queries/converters/jansson/serialize_json_01.xq'
--- test_json/Queries/converters/jansson/serialize_json_01.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/serialize_json_01.xq 1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4
5declare variable $tmp := <json type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></json>;
6
7json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
8 <json-param name="mapping" value="simple-json" type="array"/>
9 </options>)
10\ No newline at end of file0\ No newline at end of file
111
=== removed file 'test_json/Queries/converters/jansson/serialize_json_02.xq'
--- test_json/Queries/converters/jansson/serialize_json_02.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/serialize_json_02.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4declare variable $tmp := <json type="array"><pair type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></pair><pair type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></pair></json>;
5
6json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="simple-json" type="array"/>
8 </options>)
9\ No newline at end of file0\ No newline at end of file
101
=== removed file 'test_json/Queries/converters/jansson/serialize_json_03.spec'
--- test_json/Queries/converters/jansson/serialize_json_03.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_03.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM
20
=== removed file 'test_json/Queries/converters/jansson/serialize_json_03.xq'
--- test_json/Queries/converters/jansson/serialize_json_03.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/serialize_json_03.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1(: json:serialize called with wrong parameter: comment node:)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<!--comment-->),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="simple-json" type="array"/>
8 </options>)
90
=== removed file 'test_json/Queries/converters/jansson/serialize_json_04.xq'
--- test_json/Queries/converters/jansson/serialize_json_04.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_04.xq 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1(: json:serialize test escaping of double quotes :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="firstName" type="string">\"</pair>
8 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
9 <json-param name="mapping" value="simple-json" />
10 </options>)
110
=== removed file 'test_json/Queries/converters/jansson/serialize_json_05.xq'
--- test_json/Queries/converters/jansson/serialize_json_05.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_05.xq 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1(: json:serialize some pitfall characters :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="name" type="string">\"\\\/\b\f\n\r\t</pair>
8 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
9 <json-param name="mapping" value="simple-json" />
10 </options>)
110
=== removed file 'test_json/Queries/converters/jansson/serialize_json_06.spec'
--- test_json/Queries/converters/jansson/serialize_json_06.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_06.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM
20
=== removed file 'test_json/Queries/converters/jansson/serialize_json_06.xq'
--- test_json/Queries/converters/jansson/serialize_json_06.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_06.xq 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1(: type value missing :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="name" type="">value</pair>
8 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
9 <json-param name="mapping" value="simple-json" />
10 </options>)
110
=== removed file 'test_json/Queries/converters/jansson/serialize_json_07.spec'
--- test_json/Queries/converters/jansson/serialize_json_07.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_07.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM
20
=== removed file 'test_json/Queries/converters/jansson/serialize_json_07.xq'
--- test_json/Queries/converters/jansson/serialize_json_07.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_07.xq 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1(: type value wrong :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="name" type="huhu">value</pair>
8 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
9 <json-param name="mapping" value="simple-json" />
10 </options>)
110
=== removed file 'test_json/Queries/converters/jansson/serialize_json_08.spec'
--- test_json/Queries/converters/jansson/serialize_json_08.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_08.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM
20
=== removed file 'test_json/Queries/converters/jansson/serialize_json_08.xq'
--- test_json/Queries/converters/jansson/serialize_json_08.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_08.xq 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1(: wrong value for array :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="name" type="array">
8 <pair name="wrong" type="string">value</pair>
9 </pair>
10 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
11 <json-param name="mapping" value="simple-json" />
12 </options>)
130
=== removed file 'test_json/Queries/converters/jansson/serialize_json_09.xq'
--- test_json/Queries/converters/jansson/serialize_json_09.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_09.xq 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
1(: valid json generation: array in an array :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="servlet" type="array">
8 <item type="array">
9 <item type="string">value1</item>
10 </item>
11 <item type="string">value2</item>
12 </pair>
13 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
14 <json-param name="mapping" value="simple-json" />
15 </options>)
160
=== removed file 'test_json/Queries/converters/jansson/serialize_json_10.spec'
--- test_json/Queries/converters/jansson/serialize_json_10.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/serialize_json_10.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/serialize_json_10.xq'
--- test_json/Queries/converters/jansson/serialize_json_10.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_10.xq 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
1(: object contained in an array is allowed :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="servlet" type="array">
8 <item type="object">
9 <pair name="name" type="string">value1</pair>
10 </item>
11 <item type="string">value2</item>
12 </pair>
13 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
14 <json-param name="mapping" value="simple-json" />
15 </options>)
160
=== removed file 'test_json/Queries/converters/jansson/serialize_json_11.spec'
--- test_json/Queries/converters/jansson/serialize_json_11.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_11.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM
20
=== removed file 'test_json/Queries/converters/jansson/serialize_json_11.xq'
--- test_json/Queries/converters/jansson/serialize_json_11.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_11.xq 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1(: type attribute missing :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair name="name">value</pair>
8 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
9 <json-param name="mapping" value="simple-json" />
10 </options>)
110
=== removed file 'test_json/Queries/converters/jansson/serialize_json_12.spec'
--- test_json/Queries/converters/jansson/serialize_json_12.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_12.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM
20
=== removed file 'test_json/Queries/converters/jansson/serialize_json_12.xq'
--- test_json/Queries/converters/jansson/serialize_json_12.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_12.xq 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1(: name attribute missing :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6json:serialize((<json type="object">
7 <pair type="string">value</pair>
8 </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
9 <json-param name="mapping" value="simple-json" />
10 </options>)
110
=== removed file 'test_json/Queries/converters/jansson/serialize_json_13.xq'
--- test_json/Queries/converters/jansson/serialize_json_13.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_13.xq 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1(: valid json generation: comments should be ignored :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6declare variable $local:json :=
7 <json type="object">
8 <pair name="servlet" type="array">
9 <!--comment-->
10 <item type="string">value</item>
11 </pair>
12 </json>;
13
14json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
15 <json-param name="mapping" value="simple-json" />
16 </options>)
170
=== removed file 'test_json/Queries/converters/jansson/serialize_json_14.xq'
--- test_json/Queries/converters/jansson/serialize_json_14.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_14.xq 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1(: valid json generation: comments should be ignored :)
2
3import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
4import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
5
6declare variable $local:json :=
7 <json type="object">
8 <pair name="servlet" type="object">
9 <!--comment-->
10 <pair name="name" type="string">value</pair>
11 </pair>
12 </json>;
13
14json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
15 <json-param name="mapping" value="simple-json" />
16 </options>)
170
=== removed file 'test_json/Queries/converters/jansson/serialize_json_15.xq'
--- test_json/Queries/converters/jansson/serialize_json_15.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_15.xq 1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4declare variable $local:json :=<json type="object">
5 <pair name="servlet" type="array">
6 <item type="object">
7 </item>
8 </pair>
9</json>;
10
11json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
12 <json-param name="mapping" value="simple-json" />
13 </options>)
140
=== removed file 'test_json/Queries/converters/jansson/serialize_json_16.xq'
--- test_json/Queries/converters/jansson/serialize_json_16.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_16.xq 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4declare variable $local:json :=<json type="object">
5 <pair name="servlet" type="array">
6 <item type="array">
7 <item type='string'>212 732-1234</item>
8 </item>
9 </pair>
10</json>;
11
12json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
13 <json-param name="mapping" value="simple-json" />
14 </options>)
150
=== removed file 'test_json/Queries/converters/jansson/serialize_json_17.spec'
--- test_json/Queries/converters/jansson/serialize_json_17.spec 2011-05-31 15:21:09 +0000
+++ test_json/Queries/converters/jansson/serialize_json_17.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Comparison: Ignore
2\ No newline at end of file0\ No newline at end of file
31
=== removed file 'test_json/Queries/converters/jansson/serialize_json_17.xq'
--- test_json/Queries/converters/jansson/serialize_json_17.xq 2011-08-07 21:55:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_17.xq 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4
5declare variable $local:json :=
6 '{ "special-chars": {
7 "quote": "\"",
8 "backslash": "\\",
9 "backspace": "\b",
10 "formfeed": "\f",
11 "newline": "\n",
12 "carriage return": "\r",
13 "horizontal tab": "\t",
14 "solidus": "\/"
15 }
16 }';
17
18json:serialize((json:parse(($local:json),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
19 <json-param name="mapping" value="simple-json" />
20 </options>)),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
21 <json-param name="mapping" value="simple-json" />
22 </options>)
23
240
=== removed file 'test_json/Queries/converters/jansson/serialize_json_18.xq'
--- test_json/Queries/converters/jansson/serialize_json_18.xq 2011-10-06 07:40:17 +0000
+++ test_json/Queries/converters/jansson/serialize_json_18.xq 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4
5declare variable $tmp := <json type="object"><pair name="phoneNumbers" type="array"><item type="string">212 732-1234</item><item type="string">646 123-4567</item></pair><pair name="firstName" type="string">John</pair><pair name="lastName" type="string">Smith</pair><pair name="address" type="object"><pair name="postalCode" type="number">10021</pair><pair name="city" type="string">New York</pair><pair name="streetAddress" type="string">21 2nd Street</pair><pair name="state" type="string">NY</pair></pair></json>;
6
7json:serialize($tmp)
8\ No newline at end of file0\ No newline at end of file
91
=== removed file 'test_json/Queries/converters/jansson/serialize_json_ml_01.xq'
--- test_json/Queries/converters/jansson/serialize_json_ml_01.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/serialize_json_ml_01.xq 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4declare variable $tmp :=<ul>
5 <li style="color:red">First Item</li>
6 <li title="Some hover text." style="color:green">Second Item</li>
7 <li><span class="code-example-third">Third</span>Item</li>
8</ul>;
9
10json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
11 <json-param name="mapping" value="json-ml" type="array"/>
12 </options>)
13\ No newline at end of file0\ No newline at end of file
141
=== removed file 'test_json/Queries/converters/jansson/serialize_json_ml_02.xq'
--- test_json/Queries/converters/jansson/serialize_json_ml_02.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/serialize_json_ml_02.xq 1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4declare variable $tmp :=<table class="MyTable" style="background-color:yellow">
5<tr>
6<td class="MyTD" style="border:1px solid black">#5D28D1</td>
7<td class="MyTD" style="background-color:red">Example text here</td>
8</tr>
9<tr>
10<td class="MyTD" style="border:1px solid black">#AF44EF</td>
11<td class="MyTD" style="background-color:green">127310656</td>
12</tr>
13<tr>
14<td class="MyTD" style="border:1px solid black">#AAD034</td>
15<td class="MyTD" style="background-color:blue">\u00A0<span style="background-color:maroon">\u00A9</span>\u00A0</td>
16</tr>
17</table>;
18
19json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
20 <json-param name="mapping" value="json-ml" type="array"/>
21 </options>)
22\ No newline at end of file0\ No newline at end of file
231
=== removed file 'test_json/Queries/converters/jansson/serialize_json_ml_03.spec'
--- test_json/Queries/converters/jansson/serialize_json_ml_03.spec 2011-08-18 22:09:48 +0000
+++ test_json/Queries/converters/jansson/serialize_json_ml_03.spec 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM
20
=== removed file 'test_json/Queries/converters/jansson/serialize_json_ml_03.xq'
--- test_json/Queries/converters/jansson/serialize_json_ml_03.xq 2011-08-11 20:09:07 +0000
+++ test_json/Queries/converters/jansson/serialize_json_ml_03.xq 1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4declare variable $tmp :=<!--comment-->;
5
6json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" >
7 <json-param name="mapping" value="json-ml" type="array"/>
8 </options>)
9\ No newline at end of file0\ No newline at end of file
101
=== removed file 'test_json/Queries/converters/jansson/serialize_json_ml_04.xq'
--- test_json/Queries/converters/jansson/serialize_json_ml_04.xq 2011-10-06 07:40:17 +0000
+++ test_json/Queries/converters/jansson/serialize_json_ml_04.xq 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
2import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
3
4declare variable $tmp :=<ul>
5 <li style="color:red">First Item</li>
6 <li title="Some hover text." style="color:green">Second Item</li>
7 <li><span class="code-example-third">Third</span>Item</li>
8</ul>;
9
10json:serialize-ml($tmp)
11\ No newline at end of file0\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: