Merge lp:~zorba-coders/zorba/remove_old_json into lp:~zorba-coders/zorba/data-converters-module
- remove_old_json
- Merge into data-converters-module
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 |
Related bugs: |
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.
Paul J. Lucas (paul-lucas) : | # |
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
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/
Validation queue job remove_
The final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job remove_
All tests succeeded!
Preview Diff
1 | === removed file 'cmake_modules/FindJansson.cmake' | |||
2 | --- cmake_modules/FindJansson.cmake 2011-10-06 07:40:17 +0000 | |||
3 | +++ cmake_modules/FindJansson.cmake 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,64 +0,0 @@ | |||
5 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
6 | 2 | # | ||
7 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
8 | 4 | # you may not use this file except in compliance with the License. | ||
9 | 5 | # You may obtain a copy of the License at | ||
10 | 6 | # | ||
11 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
12 | 8 | # | ||
13 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
14 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
15 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
16 | 12 | # See the License for the specific language governing permissions and | ||
17 | 13 | # limitations under the License. | ||
18 | 14 | # | ||
19 | 15 | # - Find Jansson | ||
20 | 16 | # | ||
21 | 17 | # Once done this will define | ||
22 | 18 | # | ||
23 | 19 | # Jansson_FOUND - System has Jansson | ||
24 | 20 | # Jansson_INCLUDE_DIRS - The Jansson include directories | ||
25 | 21 | # Jansson_LIBRARIES - The libraries needed to use Jansson | ||
26 | 22 | |||
27 | 23 | IF (Jansson_INCLUDE AND Jansson_LIBRARY) | ||
28 | 24 | # in cache already | ||
29 | 25 | SET(Jansson_FIND_QUIETLY TRUE) | ||
30 | 26 | ENDIF (Jansson_INCLUDE AND Jansson_LIBRARY) | ||
31 | 27 | |||
32 | 28 | SET(LIBRARY_NAMES jansson jansson.lib Release/jansson.lib bin/jansson.lib bin/Release/jansson.lib) | ||
33 | 29 | FIND_LIBRARY( | ||
34 | 30 | Jansson_LIBRARY | ||
35 | 31 | NAMES ${LIBRARY_NAMES} | ||
36 | 32 | PATHS /usr/lib /usr/local/lib /opt/local/lib ${Jansson_LIBRARIES}) | ||
37 | 33 | |||
38 | 34 | FIND_PATH( | ||
39 | 35 | Jansson_INCLUDE | ||
40 | 36 | NAMES jansson.h | ||
41 | 37 | PATH_SUFFIXES jansson src | ||
42 | 38 | PATHS ${Jansson_INCLUDE_DIRS}) | ||
43 | 39 | |||
44 | 40 | IF(Jansson_LIBRARY AND Jansson_INCLUDE) | ||
45 | 41 | SET(Jansson_FOUND TRUE) | ||
46 | 42 | SET(Jansson_LIBRARIES ${Jansson_LIBRARY}) | ||
47 | 43 | SET(Jansson_INCLUDE_DIRS ${Jansson_INCLUDE}) | ||
48 | 44 | ELSE(Jansson_LIBRARY AND Jansson_INCLUDE) | ||
49 | 45 | IF(NOT Jansson_LIBRARY) | ||
50 | 46 | MESSAGE(STATUS "Jansson static library could not be found matching one of: ${LIBRARY_NAMES}") | ||
51 | 47 | ENDIF(NOT Jansson_LIBRARY) | ||
52 | 48 | IF(NOT Jansson_INCLUDE) | ||
53 | 49 | MESSAGE(STATUS "Jansson source directory could not be found.") | ||
54 | 50 | ENDIF(NOT Jansson_INCLUDE) | ||
55 | 51 | |||
56 | 52 | SET(Jansson_FOUND FALSE) | ||
57 | 53 | SET(Jansson_LIBRARIES) | ||
58 | 54 | SET(Jansson_INCLUDE) | ||
59 | 55 | ENDIF (Jansson_LIBRARY AND Jansson_INCLUDE) | ||
60 | 56 | |||
61 | 57 | IF(Jansson_FOUND) | ||
62 | 58 | IF(NOT Jansson_FIND_QUIETLY) | ||
63 | 59 | MESSAGE(STATUS "Found Jansson : ${Jansson_LIBRARY}") | ||
64 | 60 | MESSAGE(STATUS "Found Jansson include path : ${Jansson_INCLUDE_DIRS}") | ||
65 | 61 | ENDIF(NOT Jansson_FIND_QUIETLY) | ||
66 | 62 | ELSE(Jansson_FOUND) | ||
67 | 63 | MESSAGE(STATUS "Could not find Jansson library.") | ||
68 | 64 | ENDIF(Jansson_FOUND) | ||
69 | 65 | 0 | ||
70 | === modified file 'src/com/zorba-xquery/www/modules/converters/CMakeLists.txt' | |||
71 | --- src/com/zorba-xquery/www/modules/converters/CMakeLists.txt 2011-12-06 08:05:27 +0000 | |||
72 | +++ src/com/zorba-xquery/www/modules/converters/CMakeLists.txt 2012-01-23 19:42:25 +0000 | |||
73 | @@ -40,40 +40,6 @@ | |||
74 | 40 | ENDIF (ZORBA_SUPPRESS_LIBTIDY) | 40 | ENDIF (ZORBA_SUPPRESS_LIBTIDY) |
75 | 41 | MESSAGE (STATUS "") | 41 | MESSAGE (STATUS "") |
76 | 42 | 42 | ||
77 | 43 | |||
78 | 44 | # | ||
79 | 45 | # Jansson | ||
80 | 46 | # | ||
81 | 47 | IF (ZORBA_SUPPRESS_JANSSON) | ||
82 | 48 | MESSAGE (STATUS "ZORBA_SUPPRESS_JANSSON is true - not searching for Jansson.") | ||
83 | 49 | ELSE (ZORBA_SUPPRESS_JANSSON) | ||
84 | 50 | |||
85 | 51 | MESSAGE (STATUS "Looking for Jansson") | ||
86 | 52 | FIND_PACKAGE (Jansson) | ||
87 | 53 | |||
88 | 54 | IF (Jansson_FOUND) | ||
89 | 55 | MESSAGE (STATUS "Found Jansson library -- " ${Jansson_LIBRARIES}) | ||
90 | 56 | |||
91 | 57 | SET (JSON_LINK_LIBRARIES ${Jansson_LIBRARIES}) | ||
92 | 58 | INCLUDE_DIRECTORIES (${Jansson_INCLUDE_DIRS}) | ||
93 | 59 | INCLUDE_DIRECTORIES ("json.xq.src") | ||
94 | 60 | DECLARE_ZORBA_SCHEMA (FILE "json-options.xsd" | ||
95 | 61 | URI "http://www.zorba-xquery.com/modules/converters/json-options") | ||
96 | 62 | DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/converters/json" VERSION 1.0 FILE "json.xq" LINK_LIBRARIES "${Jansson_LIBRARIES}") | ||
97 | 63 | ADD_TEST_DIRECTORY ("${PROJECT_SOURCE_DIR}/test_json") | ||
98 | 64 | |||
99 | 65 | IF(ZORBA_NO_UNICODE) | ||
100 | 66 | SET_TESTS_PROPERTIES(zorba_data-converters_module/converters/jansson/parse_json_03.xq | ||
101 | 67 | PROPERTIES WILL_FAIL TRUE) | ||
102 | 68 | ENDIF(ZORBA_NO_UNICODE) | ||
103 | 69 | |||
104 | 70 | ELSE (Jansson_FOUND) | ||
105 | 71 | MESSAGE (STATUS "Jansson library not found -- if you want to use Json functionality please set Jansson_INCLUDE_DIRS and Jansson_LIBRARIES cmake parameters.") | ||
106 | 72 | ENDIF (Jansson_FOUND) | ||
107 | 73 | ENDIF (ZORBA_SUPPRESS_JANSSON) | ||
108 | 74 | MESSAGE (STATUS "") | ||
109 | 75 | |||
110 | 76 | |||
111 | 77 | # csv | 43 | # csv |
112 | 78 | DECLARE_ZORBA_SCHEMA (FILE csv-options.xsd | 44 | DECLARE_ZORBA_SCHEMA (FILE csv-options.xsd |
113 | 79 | URI "http://www.zorba-xquery.com/modules/converters/csv-options") | 45 | URI "http://www.zorba-xquery.com/modules/converters/csv-options") |
114 | @@ -97,4 +63,3 @@ | |||
115 | 97 | SET_TESTS_PROPERTIES(zorba_data-converters_module/converters/csv/csv_parse_utf8_11.xq | 63 | SET_TESTS_PROPERTIES(zorba_data-converters_module/converters/csv/csv_parse_utf8_11.xq |
116 | 98 | PROPERTIES WILL_FAIL TRUE) | 64 | PROPERTIES WILL_FAIL TRUE) |
117 | 99 | ENDIF(ZORBA_NO_UNICODE) | 65 | ENDIF(ZORBA_NO_UNICODE) |
118 | 100 | |||
119 | 101 | 66 | ||
120 | === removed file 'src/com/zorba-xquery/www/modules/converters/json-options.xsd' | |||
121 | --- src/com/zorba-xquery/www/modules/converters/json-options.xsd 2011-08-11 20:09:07 +0000 | |||
122 | +++ src/com/zorba-xquery/www/modules/converters/json-options.xsd 1970-01-01 00:00:00 +0000 | |||
123 | @@ -1,47 +0,0 @@ | |||
124 | 1 | <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
125 | 2 | xmlns:json="http://www.zorba-xquery.com/modules/converters/json-options" | ||
126 | 3 | targetNamespace="http://www.zorba-xquery.com/modules/converters/json-options" | ||
127 | 4 | elementFormDefault="qualified" attributeFormDefault="unqualified"> | ||
128 | 5 | <!-- | ||
129 | 6 | :: Copyright 2006-2008 The FLWOR Foundation. | ||
130 | 7 | :: | ||
131 | 8 | :: Licensed under the Apache License, Version 2.0 (the "License"); | ||
132 | 9 | :: you may not use this file except in compliance with the License. | ||
133 | 10 | :: You may obtain a copy of the License at | ||
134 | 11 | :: | ||
135 | 12 | :: http://www.apache.org/licenses/LICENSE-2.0 | ||
136 | 13 | :: | ||
137 | 14 | :: Unless required by applicable law or agreed to in writing, software | ||
138 | 15 | :: distributed under the License is distributed on an "AS IS" BASIS, | ||
139 | 16 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
140 | 17 | :: See the License for the specific language governing permissions and | ||
141 | 18 | :: limitations under the License. | ||
142 | 19 | :: | ||
143 | 20 | --> | ||
144 | 21 | |||
145 | 22 | |||
146 | 23 | <xs:element name="options"> | ||
147 | 24 | <xs:complexType> | ||
148 | 25 | <xs:sequence> | ||
149 | 26 | <xs:element name="json-param" minOccurs="1" maxOccurs="1"> | ||
150 | 27 | <xs:complexType> | ||
151 | 28 | <xs:simpleContent> | ||
152 | 29 | <xs:extension base="xs:string"> | ||
153 | 30 | <xs:attribute name="name" type="xs:string" use="required"/> | ||
154 | 31 | <xs:attribute name="value" use="required"> | ||
155 | 32 | <xs:simpleType> | ||
156 | 33 | <xs:restriction base="xs:string"> | ||
157 | 34 | <xs:enumeration value="simple-json"/> | ||
158 | 35 | <xs:enumeration value="json-ml"/> | ||
159 | 36 | </xs:restriction> | ||
160 | 37 | </xs:simpleType> | ||
161 | 38 | </xs:attribute> | ||
162 | 39 | <xs:attribute name="type" type="xs:string" use="optional"/> | ||
163 | 40 | </xs:extension> | ||
164 | 41 | </xs:simpleContent> | ||
165 | 42 | </xs:complexType> | ||
166 | 43 | </xs:element> | ||
167 | 44 | </xs:sequence> | ||
168 | 45 | </xs:complexType> | ||
169 | 46 | </xs:element> | ||
170 | 47 | </xs:schema> | ||
171 | 48 | 0 | ||
172 | === removed file 'src/com/zorba-xquery/www/modules/converters/json.xq' | |||
173 | --- src/com/zorba-xquery/www/modules/converters/json.xq 2012-01-09 21:58:00 +0000 | |||
174 | +++ src/com/zorba-xquery/www/modules/converters/json.xq 1970-01-01 00:00:00 +0000 | |||
175 | @@ -1,242 +0,0 @@ | |||
176 | 1 | xquery version "3.0"; | ||
177 | 2 | |||
178 | 3 | (: | ||
179 | 4 | : Copyright 2006-2009 The FLWOR Foundation. | ||
180 | 5 | : | ||
181 | 6 | : Licensed under the Apache License, Version 2.0 (the "License"); | ||
182 | 7 | : you may not use this file except in compliance with the License. | ||
183 | 8 | : You may obtain a copy of the License at | ||
184 | 9 | : | ||
185 | 10 | : http://www.apache.org/licenses/LICENSE-2.0 | ||
186 | 11 | : | ||
187 | 12 | : Unless required by applicable law or agreed to in writing, software | ||
188 | 13 | : distributed under the License is distributed on an "AS IS" BASIS, | ||
189 | 14 | : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
190 | 15 | : See the License for the specific language governing permissions and | ||
191 | 16 | : limitations under the License. | ||
192 | 17 | :) | ||
193 | 18 | |||
194 | 19 | (:~ | ||
195 | 20 | : | ||
196 | 21 | : <p>In order to enable JSON processing with XQuery, Zorba implements a set | ||
197 | 22 | : of functions that open XQuery developers the door to process JSON | ||
198 | 23 | : data. Specifically, this module provides two types of functions. Functions | ||
199 | 24 | : to: | ||
200 | 25 | : <ul> | ||
201 | 26 | : <li>parse JSON and convert it to XDM and</li> | ||
202 | 27 | : <li>serialize XDM in order to output JSON.</li> | ||
203 | 28 | : </ul> | ||
204 | 29 | : </p> | ||
205 | 30 | : | ||
206 | 31 | : <p>Both types of functions are available to parse and serialize two | ||
207 | 32 | : types of XDM-JSON mappings:<ul><li>the first mapping called in this document | ||
208 | 33 | : <strong>simple XDM-JSON</strong> has been | ||
209 | 34 | : <a href="http://john.snelson.org.uk/parsing-json-into-xquery"> | ||
210 | 35 | : proposed by John Snelson</a></li><li>the second mapping is called | ||
211 | 36 | : <a href="http://jsonml.org/">JsonML</a></li></ul>In the following, we | ||
212 | 37 | : briefly describe both mappings.</p> | ||
213 | 38 | : | ||
214 | 39 | : <h2>Simple XDM-JSON Mapping</h2> | ||
215 | 40 | : <ul><li>In order to process JSON with XQuery, Zorba implements a mapping between | ||
216 | 41 | : JSON and XML that was initially proposed by John Snelson in his article | ||
217 | 42 | : <a href="http://john.snelson.org.uk/parsing-json-into-xquery" | ||
218 | 43 | : target="_blank">Parsing JSON into XQuery</a></li></ul> | ||
219 | 44 | : | ||
220 | 45 | : <h2>JsonML Mapping</h2> | ||
221 | 46 | : <ul> | ||
222 | 47 | : <li><a href="http://jsonml.org" target="_blank">JSonML</a> (JSON Markup Language) | ||
223 | 48 | : is an application of the JSON format.</li> | ||
224 | 49 | : <li>The purpose of JSonML is to provide a compact format for transporting | ||
225 | 50 | : XML-based markup as JSon. In contrast to the <strong>simple XDM-JSON</strong> mapping described above | ||
226 | 51 | : <strong>JsonML</strong> allows a lossless conversion back and forth.</li></ul> | ||
227 | 52 | : | ||
228 | 53 | : <h2>Important Notes:</h2> | ||
229 | 54 | : <ul><li>Zorba uses the <a href="http://www.digip.org/jansson/">Jansson library</a> | ||
230 | 55 | : for manipulating JSON data.</li> | ||
231 | 56 | : <li>We have tested against the following Jansson library versions: | ||
232 | 57 | : <ul><li><a href="http://www.digip.org/jansson/doc/1.2/">Jansson 1.2.1</a></li> | ||
233 | 58 | : <li><a href="http://www.digip.org/jansson/doc/1.3/">Jansson 1.3</a></li> | ||
234 | 59 | : <li><a href="http://www.digip.org/jansson/doc/2.0/">Jansson 2.0</a></li></ul> available from | ||
235 | 60 | : <a href="http://www.digip.org/jansson/releases/">Jansson releases</a>.</li></ul> | ||
236 | 61 | : | ||
237 | 62 | : @author Sorin Nasoi | ||
238 | 63 | : @library <a href="http://www.digip.org/jansson/">Jansson library for encoding, decoding and manipulating JSON data</a> | ||
239 | 64 | : | ||
240 | 65 | : @see <a href="http://john.snelson.org.uk/parsing-json-into-xquery">Mapping proposed by John Snelson</a> | ||
241 | 66 | : @see <a href="http://jsonml.org" target="_blank">JSonML</a> | ||
242 | 67 | : @see <a href="http://www.digip.org/jansson/doc/2.0/">Jansson library for encoding, decoding and manipulating JSON data</a> | ||
243 | 68 | : @project data processing/data converters | ||
244 | 69 | : | ||
245 | 70 | :) | ||
246 | 71 | module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
247 | 72 | |||
248 | 73 | import module namespace schema = "http://www.zorba-xquery.com/modules/schema"; | ||
249 | 74 | |||
250 | 75 | import schema namespace json-options = "http://www.zorba-xquery.com/modules/converters/json-options"; | ||
251 | 76 | |||
252 | 77 | declare namespace err = "http://www.w3.org/2005/xqt-errors"; | ||
253 | 78 | |||
254 | 79 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; | ||
255 | 80 | declare option ver:module-version "1.0"; | ||
256 | 81 | |||
257 | 82 | (:~ | ||
258 | 83 | : This function parses a JSON string and returns an XDM instance according | ||
259 | 84 | : to either one of the mappings described above. | ||
260 | 85 | : | ||
261 | 86 | : @param $arg a sequence of valid JSON strings. | ||
262 | 87 | : @param $options a set of name and value pairs that provide options | ||
263 | 88 | : to configure the JSON mapping process that have to be validated against the | ||
264 | 89 | : "http://www.zorba-xquery.com/modules/converters/json-options" schema. | ||
265 | 90 | : @return a sequence of nodes according to either one of the mappings described above. | ||
266 | 91 | : @error err:XQDY0027 if $options can not be validated against the json-options schema | ||
267 | 92 | : @error json:ParseError if the JSON string passed as parameter is not | ||
268 | 93 | : valid JSON. | ||
269 | 94 | : @example test_json/Queries/converters/jansson/parse_json_02.xq | ||
270 | 95 | : @example test_json/Queries/converters/jansson/parse_json_ml_01.xq | ||
271 | 96 | :) | ||
272 | 97 | declare function json:parse( | ||
273 | 98 | $arg as xs:string?, | ||
274 | 99 | $options as element(json-options:options) | ||
275 | 100 | ) as document-node(element(*, xs:untyped)) | ||
276 | 101 | { | ||
277 | 102 | let $validated-options := if(schema:is-validated($options)) then | ||
278 | 103 | $options | ||
279 | 104 | else | ||
280 | 105 | validate{$options} | ||
281 | 106 | return | ||
282 | 107 | json:parse-internal($arg, $validated-options) | ||
283 | 108 | }; | ||
284 | 109 | |||
285 | 110 | (:~ | ||
286 | 111 | : This function parses a JSON string and returns an XDM instance according | ||
287 | 112 | : to simple XDM-JSON mapping described above. | ||
288 | 113 | : | ||
289 | 114 | : @param $arg a sequence of valid JSON strings. | ||
290 | 115 | : @return a sequence of nodes according to Simple XDM-JSON mapping described above. | ||
291 | 116 | : @error json:ParseError if the JSON string passed as parameter is not | ||
292 | 117 | : valid JSON. | ||
293 | 118 | : @example test_json/Queries/converters/jansson/parse_json_11.xq | ||
294 | 119 | :) | ||
295 | 120 | declare function json:parse( | ||
296 | 121 | $arg as xs:string? | ||
297 | 122 | ) as document-node(element(*, xs:untyped)) | ||
298 | 123 | { | ||
299 | 124 | json:parse-internal($arg, | ||
300 | 125 | validate { | ||
301 | 126 | <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
302 | 127 | <json-param name="mapping" value="simple-json" /> | ||
303 | 128 | </options> | ||
304 | 129 | } | ||
305 | 130 | ) | ||
306 | 131 | }; | ||
307 | 132 | |||
308 | 133 | (:~ | ||
309 | 134 | : This function parses a JSON string and returns an XDM instance according | ||
310 | 135 | : to JsonML mapping described above. | ||
311 | 136 | : | ||
312 | 137 | : @param $arg a sequence of valid JSON strings. | ||
313 | 138 | : @return a sequence of nodes according the JSON-ML mapping described above. | ||
314 | 139 | : @error json:ParseError if the JSON string passed as parameter is not | ||
315 | 140 | : valid JSON. | ||
316 | 141 | : @example test_json/Queries/converters/jansson/parse_json_ml_05.xq | ||
317 | 142 | :) | ||
318 | 143 | declare function json:parse-ml( | ||
319 | 144 | $arg as xs:string? | ||
320 | 145 | ) as document-node(element(*, xs:untyped)) | ||
321 | 146 | { | ||
322 | 147 | json:parse-internal($arg, | ||
323 | 148 | validate { | ||
324 | 149 | <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
325 | 150 | <json-param name="mapping" value="json-ml" type="array"/> | ||
326 | 151 | </options> | ||
327 | 152 | } | ||
328 | 153 | ) | ||
329 | 154 | }; | ||
330 | 155 | |||
331 | 156 | declare %private function json:parse-internal( | ||
332 | 157 | $html as xs:string, | ||
333 | 158 | $options as element(json-options:options)? | ||
334 | 159 | ) as document-node(element(*, xs:untyped)) external; | ||
335 | 160 | |||
336 | 161 | |||
337 | 162 | (:~ | ||
338 | 163 | : The serialize function takes a sequence of nodes as parameter and | ||
339 | 164 | : transforms each element into a valid JSON string according to one of the | ||
340 | 165 | : mappings described above. | ||
341 | 166 | : | ||
342 | 167 | : @param $xml a sequence of nodes. | ||
343 | 168 | : @param $options a set of name and value pairs that provide options | ||
344 | 169 | : to configure the JSON mapping process that have to be validated against the | ||
345 | 170 | : "http://www.zorba-xquery.com/modules/converters/json-options" schema. | ||
346 | 171 | : @return a JSON string. | ||
347 | 172 | : @error err:XQDY0027 if $options can not be validated against the json-options schema | ||
348 | 173 | : @error json:InvalidXDM if the input $xml is not a valid XDM | ||
349 | 174 | : representation of JSON or JSON ML. | ||
350 | 175 | : @example test_json/Queries/converters/jansson/serialize_json_01.xq | ||
351 | 176 | : @example test_json/Queries/converters/jansson/serialize_json_ml_01.xq | ||
352 | 177 | :) | ||
353 | 178 | declare function json:serialize( | ||
354 | 179 | $xml as item()*, | ||
355 | 180 | $options as element(json-options:options) | ||
356 | 181 | ) as xs:string | ||
357 | 182 | { | ||
358 | 183 | let $validated-options := if(schema:is-validated($options)) then | ||
359 | 184 | $options | ||
360 | 185 | else | ||
361 | 186 | validate{$options} | ||
362 | 187 | return | ||
363 | 188 | json:serialize-internal($xml, $validated-options) | ||
364 | 189 | }; | ||
365 | 190 | |||
366 | 191 | (:~ | ||
367 | 192 | : The serialize function takes a sequence of nodes as parameter and | ||
368 | 193 | : transforms each element into a valid JSON string according to the | ||
369 | 194 | : Simple XDM-JSON mapping described above | ||
370 | 195 | : | ||
371 | 196 | : @param $xml a sequence of nodes. | ||
372 | 197 | : @return a JSON string. | ||
373 | 198 | : @error json:InvalidXDM if the input $xml is not a valid XDM | ||
374 | 199 | : representation of JSON or JSON ML. | ||
375 | 200 | : @example test_json/Queries/converters/jansson/serialize_json_18.xq | ||
376 | 201 | :) | ||
377 | 202 | declare function json:serialize( | ||
378 | 203 | $xml as item()* | ||
379 | 204 | ) as xs:string | ||
380 | 205 | { | ||
381 | 206 | json:serialize-internal($xml, | ||
382 | 207 | validate { | ||
383 | 208 | <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
384 | 209 | <json-param name="mapping" value="simple-json" /> | ||
385 | 210 | </options> | ||
386 | 211 | } | ||
387 | 212 | ) | ||
388 | 213 | }; | ||
389 | 214 | |||
390 | 215 | (:~ | ||
391 | 216 | : The serialize function takes a sequence of nodes as parameter and | ||
392 | 217 | : transforms each element into a valid JSON string according to the | ||
393 | 218 | : JsonML mapping described above. | ||
394 | 219 | : | ||
395 | 220 | : @param $xml a sequence of nodes. | ||
396 | 221 | : @return a JSON string. | ||
397 | 222 | : @error json:InvalidXDM if the input $xml is not a valid XDM | ||
398 | 223 | : representation of JSON or JSON ML. | ||
399 | 224 | : @example test_json/Queries/converters/jansson/serialize_json_ml_04.xq | ||
400 | 225 | :) | ||
401 | 226 | declare function json:serialize-ml( | ||
402 | 227 | $xml as item()* | ||
403 | 228 | ) as xs:string | ||
404 | 229 | { | ||
405 | 230 | json:serialize-internal($xml, | ||
406 | 231 | validate { | ||
407 | 232 | <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
408 | 233 | <json-param name="mapping" value="json-ml" type="array"/> | ||
409 | 234 | </options> | ||
410 | 235 | } | ||
411 | 236 | ) | ||
412 | 237 | }; | ||
413 | 238 | |||
414 | 239 | declare %private function json:serialize-internal( | ||
415 | 240 | $xml as item()*, | ||
416 | 241 | $options as element(json-options:options)? | ||
417 | 242 | ) as xs:string external; | ||
418 | 243 | 0 | ||
419 | === removed directory 'src/com/zorba-xquery/www/modules/converters/json.xq.src' | |||
420 | === removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp' | |||
421 | --- src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp 2011-12-07 19:24:59 +0000 | |||
422 | +++ src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp 1970-01-01 00:00:00 +0000 | |||
423 | @@ -1,729 +0,0 @@ | |||
424 | 1 | /* | ||
425 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
426 | 3 | * | ||
427 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
428 | 5 | * you may not use this file except in compliance with the License. | ||
429 | 6 | * You may obtain a copy of the License at | ||
430 | 7 | * | ||
431 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
432 | 9 | * | ||
433 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
434 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
435 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
436 | 13 | * See the License for the specific language governing permissions and | ||
437 | 14 | * limitations under the License. | ||
438 | 15 | */ | ||
439 | 16 | |||
440 | 17 | #include <sstream> | ||
441 | 18 | #include <cstring> | ||
442 | 19 | |||
443 | 20 | #include <zorba/zorba.h> | ||
444 | 21 | #include <zorba/iterator.h> | ||
445 | 22 | #include <zorba/store_consts.h> | ||
446 | 23 | |||
447 | 24 | #include <jansson.h> | ||
448 | 25 | |||
449 | 26 | #include "jansson_wrapper.h" | ||
450 | 27 | |||
451 | 28 | namespace zorba | ||
452 | 29 | { | ||
453 | 30 | namespace jsonmodule | ||
454 | 31 | { | ||
455 | 32 | static void serialize_child( | ||
456 | 33 | const zorba::Item& aElement, | ||
457 | 34 | std::stringstream& aResultSs, | ||
458 | 35 | std::stringstream& aErrorLogSs, | ||
459 | 36 | const std::string& aParentType); | ||
460 | 37 | |||
461 | 38 | bool replace_all( std::string &s, char from, char to ) { | ||
462 | 39 | bool replaced_any = false; | ||
463 | 40 | for ( std::string::size_type pos = 0; pos < s.size(); ++pos ) { | ||
464 | 41 | if ( (pos = s.find( from, pos )) == std::string::npos ) | ||
465 | 42 | break; | ||
466 | 43 | s.replace( pos, 1, 1, to ); | ||
467 | 44 | replaced_any = true; | ||
468 | 45 | } | ||
469 | 46 | return replaced_any; | ||
470 | 47 | } | ||
471 | 48 | |||
472 | 49 | bool replace_all( std::string &s, | ||
473 | 50 | char const *from, std::string::size_type from_len, | ||
474 | 51 | char const *to, std::string::size_type to_len ) { | ||
475 | 52 | bool replaced_any = false; | ||
476 | 53 | for ( std::string::size_type pos = 0; | ||
477 | 54 | pos + from_len <= s.size(); pos += to_len ) { | ||
478 | 55 | if ( (pos = s.find( from, pos, from_len )) == std::string::npos ) | ||
479 | 56 | break; | ||
480 | 57 | s.replace( pos, from_len, to, to_len ); | ||
481 | 58 | replaced_any = true; | ||
482 | 59 | } | ||
483 | 60 | return replaced_any; | ||
484 | 61 | } | ||
485 | 62 | |||
486 | 63 | bool replace_all( std::string &s, char const *from, char const *to ) | ||
487 | 64 | { | ||
488 | 65 | return replace_all( s, from, std::strlen( from ), to, std::strlen( to ) ); | ||
489 | 66 | } | ||
490 | 67 | |||
491 | 68 | void replace_special_chars( | ||
492 | 69 | std::string &aValue) | ||
493 | 70 | { | ||
494 | 71 | replace_all(aValue, "\"", "\\\"" ); //quotation mark | ||
495 | 72 | replace_all(aValue, "\\", "\\\\" ); //reverse solidus | ||
496 | 73 | replace_all(aValue, "/" , "\\/" ); //solidus | ||
497 | 74 | replace_all(aValue, "\b", "\\b" ); //backspace | ||
498 | 75 | replace_all(aValue, "\f", "\\f" ); //formfeed | ||
499 | 76 | replace_all(aValue, "\n", "\\n" ); //new line | ||
500 | 77 | replace_all(aValue, "\r", "\\r" ); //carriage return | ||
501 | 78 | replace_all(aValue, "\t", "\\t" ); //horizontal tab | ||
502 | 79 | replace_all(aValue, "<" , "<" ); // < | ||
503 | 80 | replace_all(aValue, ">" , ">" ); // > | ||
504 | 81 | } | ||
505 | 82 | |||
506 | 83 | static void parse_Json_value( | ||
507 | 84 | const char *aKey, | ||
508 | 85 | json_t *aValue, | ||
509 | 86 | const char* aParentType, | ||
510 | 87 | std::stringstream& aSs, | ||
511 | 88 | std::stringstream& aErrorLogSs) | ||
512 | 89 | { | ||
513 | 90 | if(!aValue) | ||
514 | 91 | return; | ||
515 | 92 | |||
516 | 93 | switch(json_typeof(aValue)) | ||
517 | 94 | { | ||
518 | 95 | case JSON_OBJECT: | ||
519 | 96 | { | ||
520 | 97 | const char *lKey; | ||
521 | 98 | json_t *lValue; | ||
522 | 99 | std::string lTmp(aKey); | ||
523 | 100 | |||
524 | 101 | //<pair name=\"[...]\" type=\"object\">[...]</pair> | ||
525 | 102 | aSs << "<pair"; | ||
526 | 103 | if(!lTmp.empty()) | ||
527 | 104 | aSs << " name=\"" << lTmp << "\""; | ||
528 | 105 | aSs << " type=\"object\">"; | ||
529 | 106 | |||
530 | 107 | void *lIter = json_object_iter(aValue); | ||
531 | 108 | while(lIter) | ||
532 | 109 | { | ||
533 | 110 | lKey = json_object_iter_key(lIter); | ||
534 | 111 | lValue = json_object_iter_value(lIter); | ||
535 | 112 | |||
536 | 113 | parse_Json_value(lKey, lValue, "object", aSs, aErrorLogSs); | ||
537 | 114 | |||
538 | 115 | lIter = json_object_iter_next(aValue, lIter); | ||
539 | 116 | } | ||
540 | 117 | |||
541 | 118 | aSs << "</pair>"; | ||
542 | 119 | break; | ||
543 | 120 | } | ||
544 | 121 | case JSON_ARRAY: | ||
545 | 122 | { | ||
546 | 123 | json_t *lValue; | ||
547 | 124 | zorba::String lName(aKey), lEmptyStr(""); | ||
548 | 125 | |||
549 | 126 | //<pair name=\"[...]\" type=\"array\">[...]</pair> | ||
550 | 127 | aSs << "<pair name=\"" << lName << "\" type=\"array\">"; | ||
551 | 128 | |||
552 | 129 | for(size_t i = 0; i < json_array_size(aValue); i++) | ||
553 | 130 | { | ||
554 | 131 | lValue = json_array_get(aValue, i); | ||
555 | 132 | |||
556 | 133 | parse_Json_value(lEmptyStr.c_str(), lValue, "array", aSs, aErrorLogSs); | ||
557 | 134 | } | ||
558 | 135 | |||
559 | 136 | aSs << "</pair>"; | ||
560 | 137 | break; | ||
561 | 138 | } | ||
562 | 139 | default: | ||
563 | 140 | { | ||
564 | 141 | //only NULL does not have a value | ||
565 | 142 | bool lHaveVal = !(json_is_null(aValue)); | ||
566 | 143 | |||
567 | 144 | std::string lType, lValue; | ||
568 | 145 | if(json_is_null(aValue)) | ||
569 | 146 | { | ||
570 | 147 | lType = "null"; | ||
571 | 148 | lValue = "null"; | ||
572 | 149 | } | ||
573 | 150 | else if(json_is_string(aValue)) | ||
574 | 151 | { | ||
575 | 152 | lType = "string"; | ||
576 | 153 | lValue = json_string_value(aValue); | ||
577 | 154 | } | ||
578 | 155 | else if(json_is_number(aValue)) | ||
579 | 156 | { | ||
580 | 157 | lType = "number"; | ||
581 | 158 | |||
582 | 159 | //json_string_value works just for STRING items so we have to use | ||
583 | 160 | //json_number_value that returns a double | ||
584 | 161 | std::ostringstream lOss; | ||
585 | 162 | lOss << json_number_value(aValue); | ||
586 | 163 | lValue = lOss.str(); | ||
587 | 164 | } | ||
588 | 165 | else if(json_is_boolean(aValue)) | ||
589 | 166 | { | ||
590 | 167 | lType = "boolean"; | ||
591 | 168 | lValue = json_is_true(aValue)?"true":"false"; | ||
592 | 169 | } | ||
593 | 170 | |||
594 | 171 | zorba::String lName(aKey); | ||
595 | 172 | std::string lParent(aParentType); | ||
596 | 173 | std::string lItemName = (lParent.compare("object") == 0)?"pair":"item"; | ||
597 | 174 | |||
598 | 175 | |||
599 | 176 | aSs << "<" << lItemName; | ||
600 | 177 | if(!lName.empty()) | ||
601 | 178 | { | ||
602 | 179 | aSs <<" name=\"" << lName << "\""; | ||
603 | 180 | } | ||
604 | 181 | aSs << " type=\"" << lType; | ||
605 | 182 | if(lHaveVal) | ||
606 | 183 | { | ||
607 | 184 | replace_special_chars(lValue); | ||
608 | 185 | aSs << "\">" << lValue << "</" << lItemName << ">"; | ||
609 | 186 | } | ||
610 | 187 | else | ||
611 | 188 | aSs << "\"/>"; | ||
612 | 189 | |||
613 | 190 | break; | ||
614 | 191 | } | ||
615 | 192 | } | ||
616 | 193 | } | ||
617 | 194 | |||
618 | 195 | |||
619 | 196 | void JSON_parse( | ||
620 | 197 | const char* aJsonString, | ||
621 | 198 | std::stringstream& aSs, | ||
622 | 199 | std::stringstream& aErrorLogSs) | ||
623 | 200 | { | ||
624 | 201 | json_error_t lerror; | ||
625 | 202 | json_t *ljson; | ||
626 | 203 | |||
627 | 204 | #if JANSSON_MAJOR_VERSION < 2 | ||
628 | 205 | ljson = json_loads(aJsonString, &lerror); | ||
629 | 206 | #else | ||
630 | 207 | ljson = json_loads(aJsonString, 0, &lerror); | ||
631 | 208 | #endif | ||
632 | 209 | |||
633 | 210 | if(!ljson) | ||
634 | 211 | { | ||
635 | 212 | #if JANSSON_MAJOR_VERSION < 2 | ||
636 | 213 | aErrorLogSs << "Error at line: " << lerror.line << std::endl; | ||
637 | 214 | aErrorLogSs << lerror.text << std::endl; | ||
638 | 215 | #else | ||
639 | 216 | aErrorLogSs << "Error at line: " << lerror.line << " column: " << lerror.column << " position: " << lerror.position << std::endl; | ||
640 | 217 | aErrorLogSs << lerror.text << std::endl; | ||
641 | 218 | #endif | ||
642 | 219 | return; | ||
643 | 220 | } | ||
644 | 221 | |||
645 | 222 | const char *lKey; | ||
646 | 223 | json_t *lValue; | ||
647 | 224 | lKey = json_object_iter_key(ljson); | ||
648 | 225 | |||
649 | 226 | if(json_is_object(ljson)) | ||
650 | 227 | { | ||
651 | 228 | aSs << "<json type=\"object\">"; | ||
652 | 229 | void *lIter = json_object_iter(ljson); | ||
653 | 230 | while(lIter) | ||
654 | 231 | { | ||
655 | 232 | lKey = json_object_iter_key(lIter); | ||
656 | 233 | lValue = json_object_iter_value(lIter); | ||
657 | 234 | |||
658 | 235 | parse_Json_value(lKey, lValue, "object", aSs, aErrorLogSs); | ||
659 | 236 | |||
660 | 237 | lIter = json_object_iter_next(ljson, lIter); | ||
661 | 238 | } | ||
662 | 239 | aSs << "</json>"; | ||
663 | 240 | } | ||
664 | 241 | else if(json_is_array(ljson)) | ||
665 | 242 | { | ||
666 | 243 | std::string lEmptyStr(""); | ||
667 | 244 | aSs << "<json type=\"array\">"; | ||
668 | 245 | for(size_t i = 0; i < json_array_size(ljson); i++) | ||
669 | 246 | { | ||
670 | 247 | lValue = json_array_get(ljson, i); | ||
671 | 248 | |||
672 | 249 | parse_Json_value(lEmptyStr.c_str(), lValue, "array", aSs, aErrorLogSs); | ||
673 | 250 | } | ||
674 | 251 | aSs << "</json>"; | ||
675 | 252 | } | ||
676 | 253 | else | ||
677 | 254 | aErrorLogSs << "Either one of ARRAY and OBJECT are considered valid JSON." << std::endl; | ||
678 | 255 | |||
679 | 256 | } | ||
680 | 257 | |||
681 | 258 | void get_text_value( | ||
682 | 259 | const zorba::Item& aElement, | ||
683 | 260 | zorba::String& aValue) | ||
684 | 261 | { | ||
685 | 262 | zorba::Iterator_t lChildrenIt; | ||
686 | 263 | zorba::Item lChild; | ||
687 | 264 | |||
688 | 265 | lChildrenIt = aElement.getChildren(); | ||
689 | 266 | lChildrenIt->open(); | ||
690 | 267 | while (lChildrenIt->next(lChild)) | ||
691 | 268 | { | ||
692 | 269 | if (lChild.getNodeKind() == store::StoreConsts::textNode) | ||
693 | 270 | aValue = lChild.getStringValue(); | ||
694 | 271 | } | ||
695 | 272 | lChildrenIt->close(); | ||
696 | 273 | } | ||
697 | 274 | |||
698 | 275 | void serialize_element( | ||
699 | 276 | const zorba::Item& aElement, | ||
700 | 277 | std::stringstream& aResultSs, | ||
701 | 278 | std::stringstream& aErrorLogSs, | ||
702 | 279 | const std::string& aParentType) | ||
703 | 280 | { | ||
704 | 281 | zorba::Iterator_t lAttrIt, lChildrenIt; | ||
705 | 282 | zorba::Item lAttr, lChild; | ||
706 | 283 | zorba::String lName, lType; | ||
707 | 284 | |||
708 | 285 | Item lNodeNameItem; | ||
709 | 286 | aElement.getNodeName(lNodeNameItem); | ||
710 | 287 | |||
711 | 288 | if(((aParentType.compare("object") == 0) && | ||
712 | 289 | !(lNodeNameItem.getStringValue() == "pair" || lNodeNameItem.getStringValue() == "json")) || | ||
713 | 290 | ((aParentType.compare("array") == 0) && lNodeNameItem.getStringValue() != "item")) | ||
714 | 291 | { | ||
715 | 292 | aErrorLogSs << "'Object' should have only 'pair' children and 'array' should have only 'item' children." << std::endl; | ||
716 | 293 | return; | ||
717 | 294 | } | ||
718 | 295 | |||
719 | 296 | lAttrIt = aElement.getAttributes(); | ||
720 | 297 | lAttrIt->open(); | ||
721 | 298 | while (lAttrIt->next(lAttr)) | ||
722 | 299 | { | ||
723 | 300 | if(lAttr.getNodeKind() == store::StoreConsts::attributeNode) | ||
724 | 301 | { | ||
725 | 302 | Item lNodeNameItem; | ||
726 | 303 | lAttr.getNodeName(lNodeNameItem); | ||
727 | 304 | if(lNodeNameItem.getStringValue() == "type") | ||
728 | 305 | lType = lAttr.getStringValue(); | ||
729 | 306 | else if(lNodeNameItem.getStringValue() == "name") | ||
730 | 307 | lName = lAttr.getStringValue(); | ||
731 | 308 | } | ||
732 | 309 | } | ||
733 | 310 | lAttrIt->close(); | ||
734 | 311 | |||
735 | 312 | if(lType.empty()) | ||
736 | 313 | { | ||
737 | 314 | aErrorLogSs << "Element does not have a 'type' attribute defined." << std::endl; | ||
738 | 315 | return; | ||
739 | 316 | } | ||
740 | 317 | |||
741 | 318 | if(lType == "object") | ||
742 | 319 | { | ||
743 | 320 | if(!lName.empty()) | ||
744 | 321 | aResultSs << "\"" << lName.c_str() << "\": "; | ||
745 | 322 | |||
746 | 323 | //serialize every children | ||
747 | 324 | aResultSs << "{"; | ||
748 | 325 | serialize_child(aElement, aResultSs, aErrorLogSs, "object"); | ||
749 | 326 | aResultSs << "}"; | ||
750 | 327 | } | ||
751 | 328 | else if(lType == "array") | ||
752 | 329 | { | ||
753 | 330 | if(!lName.empty()) | ||
754 | 331 | aResultSs << "\"" << lName.c_str() << "\": "; | ||
755 | 332 | |||
756 | 333 | //serialize every children | ||
757 | 334 | aResultSs << "["; | ||
758 | 335 | serialize_child(aElement, aResultSs, aErrorLogSs, "array"); | ||
759 | 336 | aResultSs << "]"; | ||
760 | 337 | } | ||
761 | 338 | else if(lType == "string") | ||
762 | 339 | { | ||
763 | 340 | zorba::String lValue; | ||
764 | 341 | get_text_value(aElement, lValue); | ||
765 | 342 | zorba::Item lNodeNameItem; | ||
766 | 343 | aElement.getNodeName(lNodeNameItem); | ||
767 | 344 | if(lNodeNameItem.getStringValue() == "pair") | ||
768 | 345 | { | ||
769 | 346 | if(lName.empty()) | ||
770 | 347 | { | ||
771 | 348 | aErrorLogSs << "Element does not have a 'name' attribute defined." << std::endl; | ||
772 | 349 | return; | ||
773 | 350 | } | ||
774 | 351 | if(aParentType.compare("object") != 0) | ||
775 | 352 | { | ||
776 | 353 | aErrorLogSs << "'Pair' is allowed only as part of an object." << std::endl; | ||
777 | 354 | return; | ||
778 | 355 | } | ||
779 | 356 | aResultSs << "\"" << lName.c_str() << "\": "; | ||
780 | 357 | } | ||
781 | 358 | aResultSs << "\"" << lValue.c_str() << "\""; | ||
782 | 359 | } | ||
783 | 360 | else if(lType == "null") | ||
784 | 361 | { | ||
785 | 362 | zorba::Item lNodeNameItem; | ||
786 | 363 | aElement.getNodeName(lNodeNameItem); | ||
787 | 364 | if(lNodeNameItem.getStringValue() == "pair") | ||
788 | 365 | { | ||
789 | 366 | aResultSs << "\"" << lName.c_str() << "\": "; | ||
790 | 367 | } | ||
791 | 368 | aResultSs << "null"; | ||
792 | 369 | } | ||
793 | 370 | else if(lType == "number" || | ||
794 | 371 | lType == "boolean") | ||
795 | 372 | { | ||
796 | 373 | zorba::String lValue; | ||
797 | 374 | get_text_value(aElement, lValue); | ||
798 | 375 | zorba::Item lNodeNameItem; | ||
799 | 376 | aElement.getNodeName(lNodeNameItem); | ||
800 | 377 | if(lNodeNameItem.getStringValue() == "pair") | ||
801 | 378 | { | ||
802 | 379 | aResultSs << "\"" << lName.c_str() << "\": "; | ||
803 | 380 | } | ||
804 | 381 | aResultSs << lValue.c_str(); | ||
805 | 382 | } | ||
806 | 383 | else | ||
807 | 384 | { | ||
808 | 385 | aErrorLogSs << "Type '" << lType.c_str() << "' not recognized." << std::endl; | ||
809 | 386 | return; | ||
810 | 387 | } | ||
811 | 388 | } | ||
812 | 389 | |||
813 | 390 | void serialize_child( | ||
814 | 391 | const zorba::Item& aElement, | ||
815 | 392 | std::stringstream& aResultSs, | ||
816 | 393 | std::stringstream& aErrorLogSs, | ||
817 | 394 | const std::string& aParentType) | ||
818 | 395 | { | ||
819 | 396 | bool lFirst = true; | ||
820 | 397 | zorba::Iterator_t lChildrenIt; | ||
821 | 398 | zorba::Item lChild; | ||
822 | 399 | |||
823 | 400 | lChildrenIt = aElement.getChildren(); | ||
824 | 401 | lChildrenIt->open(); | ||
825 | 402 | while (lChildrenIt->next(lChild)) | ||
826 | 403 | { | ||
827 | 404 | if(lChild.getNodeKind() == store::StoreConsts::elementNode) | ||
828 | 405 | { | ||
829 | 406 | if(!lFirst) | ||
830 | 407 | aResultSs << ", "; | ||
831 | 408 | |||
832 | 409 | serialize_element(lChild, aResultSs, aErrorLogSs, aParentType); | ||
833 | 410 | lFirst = false; | ||
834 | 411 | } | ||
835 | 412 | } | ||
836 | 413 | lChildrenIt->close(); | ||
837 | 414 | } | ||
838 | 415 | |||
839 | 416 | void JSON_serialize( | ||
840 | 417 | const zorba::Item& aElement, | ||
841 | 418 | std::stringstream& aResultSs, | ||
842 | 419 | std::stringstream& aErrorLogSs) | ||
843 | 420 | { | ||
844 | 421 | if (aElement.isNull()) | ||
845 | 422 | { | ||
846 | 423 | aErrorLogSs << "Passed a NULL element to the JSON serializer." << std::endl; | ||
847 | 424 | return; | ||
848 | 425 | } | ||
849 | 426 | |||
850 | 427 | if(!(aElement.getNodeKind() == store::StoreConsts::documentNode || | ||
851 | 428 | aElement.getNodeKind() == store::StoreConsts::elementNode)) | ||
852 | 429 | { | ||
853 | 430 | aErrorLogSs << "Passed an incorrect Item to the JSON serializer." << std::endl; | ||
854 | 431 | return; | ||
855 | 432 | } | ||
856 | 433 | |||
857 | 434 | Item lNodeNameItem; | ||
858 | 435 | aElement.getNodeName(lNodeNameItem); | ||
859 | 436 | |||
860 | 437 | if(!lNodeNameItem.isNull() && lNodeNameItem.getStringValue() != "json") | ||
861 | 438 | { | ||
862 | 439 | aErrorLogSs << "This is not a JSON element." << std::endl; | ||
863 | 440 | return; | ||
864 | 441 | } | ||
865 | 442 | |||
866 | 443 | if(aElement.getNodeKind() == store::StoreConsts::documentNode) | ||
867 | 444 | { | ||
868 | 445 | serialize_child(aElement, aResultSs, aErrorLogSs, "object"); | ||
869 | 446 | return; | ||
870 | 447 | } | ||
871 | 448 | |||
872 | 449 | zorba::Iterator_t lAttrIt; | ||
873 | 450 | zorba::Item lAttr; | ||
874 | 451 | zorba::String lType; | ||
875 | 452 | lAttrIt = aElement.getAttributes(); | ||
876 | 453 | lAttrIt->open(); | ||
877 | 454 | while (lAttrIt->next(lAttr)) | ||
878 | 455 | { | ||
879 | 456 | if(lAttr.getNodeKind() == store::StoreConsts::attributeNode) | ||
880 | 457 | { | ||
881 | 458 | Item lNodeNameItem; | ||
882 | 459 | lAttr.getNodeName(lNodeNameItem); | ||
883 | 460 | if(lNodeNameItem.getStringValue() == "type") | ||
884 | 461 | lType = lAttr.getStringValue(); | ||
885 | 462 | else | ||
886 | 463 | { | ||
887 | 464 | aErrorLogSs << "Could not retrieve the type of the Json root." << std::endl; | ||
888 | 465 | return; | ||
889 | 466 | } | ||
890 | 467 | } | ||
891 | 468 | } | ||
892 | 469 | lAttrIt->close(); | ||
893 | 470 | |||
894 | 471 | |||
895 | 472 | if(lType == "object") | ||
896 | 473 | aResultSs << "{"; | ||
897 | 474 | else | ||
898 | 475 | aResultSs << "["; | ||
899 | 476 | |||
900 | 477 | serialize_child(aElement, aResultSs, aErrorLogSs, "object"); | ||
901 | 478 | |||
902 | 479 | if(lType == "object") | ||
903 | 480 | aResultSs << "}"; | ||
904 | 481 | else | ||
905 | 482 | aResultSs << "]"; | ||
906 | 483 | } | ||
907 | 484 | |||
908 | 485 | static void parse_JSON_ML_value( | ||
909 | 486 | const char *aKey, | ||
910 | 487 | json_t *aValue, | ||
911 | 488 | const char* aParentType, | ||
912 | 489 | std::stringstream& aSs, | ||
913 | 490 | std::stringstream& aErrorLogSs, | ||
914 | 491 | bool aShouldClose = false) | ||
915 | 492 | { | ||
916 | 493 | if(!aValue) | ||
917 | 494 | return; | ||
918 | 495 | |||
919 | 496 | switch(json_typeof(aValue)) | ||
920 | 497 | { | ||
921 | 498 | case JSON_OBJECT: | ||
922 | 499 | { | ||
923 | 500 | const char *lKey; | ||
924 | 501 | json_t *lValue; | ||
925 | 502 | std::string lTmp(aKey); | ||
926 | 503 | |||
927 | 504 | void *lIter = json_object_iter(aValue); | ||
928 | 505 | while(lIter) | ||
929 | 506 | { | ||
930 | 507 | lKey = json_object_iter_key(lIter); | ||
931 | 508 | lValue = json_object_iter_value(lIter); | ||
932 | 509 | |||
933 | 510 | parse_JSON_ML_value(lKey, lValue, "object", aSs, aErrorLogSs); | ||
934 | 511 | |||
935 | 512 | lIter = json_object_iter_next(aValue, lIter); | ||
936 | 513 | } | ||
937 | 514 | aSs << ">"; | ||
938 | 515 | break; | ||
939 | 516 | } | ||
940 | 517 | case JSON_ARRAY: | ||
941 | 518 | { | ||
942 | 519 | json_t *lValue; | ||
943 | 520 | zorba::String lName(""), lEmptyStr(""); | ||
944 | 521 | bool lShouldClose = true; | ||
945 | 522 | |||
946 | 523 | std::string lParent(aParentType); | ||
947 | 524 | if(lParent.compare("array") == 0) | ||
948 | 525 | { | ||
949 | 526 | for(size_t i = 0; i < json_array_size(aValue); i++) | ||
950 | 527 | { | ||
951 | 528 | lValue = json_array_get(aValue, i); | ||
952 | 529 | |||
953 | 530 | if(json_is_object(lValue)) | ||
954 | 531 | lShouldClose = false; | ||
955 | 532 | } | ||
956 | 533 | |||
957 | 534 | aSs << "<"; | ||
958 | 535 | } | ||
959 | 536 | |||
960 | 537 | std::string lTmp; | ||
961 | 538 | for(size_t i = 0; i < json_array_size(aValue); i++) | ||
962 | 539 | { | ||
963 | 540 | lValue = json_array_get(aValue, i); | ||
964 | 541 | |||
965 | 542 | parse_JSON_ML_value(lEmptyStr.c_str(), lValue, "array", aSs, aErrorLogSs, lShouldClose); | ||
966 | 543 | |||
967 | 544 | if(lShouldClose) | ||
968 | 545 | lShouldClose = false; | ||
969 | 546 | } | ||
970 | 547 | |||
971 | 548 | lValue = json_array_get(aValue, 0); | ||
972 | 549 | if(json_is_string(lValue)) | ||
973 | 550 | lName = json_string_value(lValue); | ||
974 | 551 | |||
975 | 552 | if(lParent.compare("array") == 0) | ||
976 | 553 | aSs << "</" << lName << ">"; | ||
977 | 554 | |||
978 | 555 | break; | ||
979 | 556 | } | ||
980 | 557 | default: | ||
981 | 558 | { | ||
982 | 559 | std::string lType, lValue; | ||
983 | 560 | if(json_is_string(aValue)) | ||
984 | 561 | { | ||
985 | 562 | lType = "string"; | ||
986 | 563 | lValue = json_string_value(aValue); | ||
987 | 564 | } | ||
988 | 565 | else if(json_is_boolean(aValue)) | ||
989 | 566 | { | ||
990 | 567 | lType = json_is_true(aValue)?"true":"false"; | ||
991 | 568 | lValue = lType; | ||
992 | 569 | } | ||
993 | 570 | else if(json_is_number(aValue)) | ||
994 | 571 | { | ||
995 | 572 | lType = "number"; | ||
996 | 573 | |||
997 | 574 | //json_string_value works just for STRING items so we have to use | ||
998 | 575 | //json_number_value that returns a double | ||
999 | 576 | std::ostringstream lOss; | ||
1000 | 577 | lOss << json_number_value(aValue); | ||
1001 | 578 | lValue = lOss.str(); | ||
1002 | 579 | } | ||
1003 | 580 | else if(json_is_null(aValue)) | ||
1004 | 581 | { | ||
1005 | 582 | lType = lValue = "null"; | ||
1006 | 583 | } | ||
1007 | 584 | |||
1008 | 585 | zorba::String lName(aKey); | ||
1009 | 586 | std::string lParent(aParentType); | ||
1010 | 587 | |||
1011 | 588 | if(lParent.compare("array") == 0) | ||
1012 | 589 | aSs << lValue; | ||
1013 | 590 | else if(lParent.compare("object") == 0) | ||
1014 | 591 | { | ||
1015 | 592 | aSs << " " << lName << "="; | ||
1016 | 593 | replace_special_chars(lValue); | ||
1017 | 594 | if(lType.compare("string") == 0) | ||
1018 | 595 | aSs << "\"" << lValue << "\""; | ||
1019 | 596 | else | ||
1020 | 597 | aSs << lValue; | ||
1021 | 598 | } | ||
1022 | 599 | |||
1023 | 600 | if(aShouldClose) | ||
1024 | 601 | aSs << ">"; | ||
1025 | 602 | |||
1026 | 603 | break; | ||
1027 | 604 | } | ||
1028 | 605 | } | ||
1029 | 606 | } | ||
1030 | 607 | |||
1031 | 608 | void JSON_ML_parse( | ||
1032 | 609 | const char* aJsonString, | ||
1033 | 610 | std::stringstream& aSs, | ||
1034 | 611 | std::stringstream& aErrorLogSs) | ||
1035 | 612 | { | ||
1036 | 613 | json_error_t lerror; | ||
1037 | 614 | json_t *ljson; | ||
1038 | 615 | zorba::String lEmptyStr(""); | ||
1039 | 616 | |||
1040 | 617 | #if JANSSON_MAJOR_VERSION < 2 | ||
1041 | 618 | ljson = json_loads(aJsonString, &lerror); | ||
1042 | 619 | #else | ||
1043 | 620 | ljson = json_loads(aJsonString, 0, &lerror); | ||
1044 | 621 | #endif | ||
1045 | 622 | if(!ljson) | ||
1046 | 623 | { | ||
1047 | 624 | #if JANSSON_MAJOR_VERSION < 2 | ||
1048 | 625 | aErrorLogSs << "Error at line: " << lerror.line << std::endl; | ||
1049 | 626 | aErrorLogSs << lerror.text << std::endl; | ||
1050 | 627 | #else | ||
1051 | 628 | aErrorLogSs << "Error at line: " << lerror.line << " column: " << lerror.column << " position: " << lerror.position << std::endl; | ||
1052 | 629 | aErrorLogSs << lerror.text << std::endl; | ||
1053 | 630 | #endif | ||
1054 | 631 | return; | ||
1055 | 632 | } | ||
1056 | 633 | |||
1057 | 634 | if(!json_is_array(ljson)) | ||
1058 | 635 | aErrorLogSs << "ARRAY is the only accepted root for the Json-ML mapping." << std::endl; | ||
1059 | 636 | |||
1060 | 637 | parse_JSON_ML_value(lEmptyStr.c_str(), ljson, "array", aSs, aErrorLogSs); | ||
1061 | 638 | } | ||
1062 | 639 | |||
1063 | 640 | void JSON_ML_serialize( | ||
1064 | 641 | const zorba::Item& aElement, | ||
1065 | 642 | std::stringstream& aResultSs, | ||
1066 | 643 | std::stringstream& aErrorLogSs) | ||
1067 | 644 | { | ||
1068 | 645 | if (aElement.isNull()) | ||
1069 | 646 | { | ||
1070 | 647 | aErrorLogSs << "Passed a NULL element to the JSON serializer." << std::endl; | ||
1071 | 648 | return; | ||
1072 | 649 | } | ||
1073 | 650 | |||
1074 | 651 | if(!(aElement.getNodeKind() == store::StoreConsts::documentNode || | ||
1075 | 652 | aElement.getNodeKind() == store::StoreConsts::elementNode || | ||
1076 | 653 | aElement.getNodeKind() == store::StoreConsts::textNode)) | ||
1077 | 654 | { | ||
1078 | 655 | aErrorLogSs << "Passed an incorrect Item to the JSON serializer." << std::endl; | ||
1079 | 656 | return; | ||
1080 | 657 | } | ||
1081 | 658 | |||
1082 | 659 | if(aElement.getNodeKind() == store::StoreConsts::textNode) | ||
1083 | 660 | { | ||
1084 | 661 | aResultSs << "\"" << aElement.getStringValue().c_str() << "\""; | ||
1085 | 662 | return; | ||
1086 | 663 | } | ||
1087 | 664 | |||
1088 | 665 | Item lNodeNameItem; | ||
1089 | 666 | aElement.getNodeName(lNodeNameItem); | ||
1090 | 667 | |||
1091 | 668 | aResultSs << "[\"" << lNodeNameItem.getStringValue().c_str() << "\""; | ||
1092 | 669 | |||
1093 | 670 | zorba::Iterator_t lAttrIt; | ||
1094 | 671 | zorba::Item lAttr; | ||
1095 | 672 | zorba::String lType; | ||
1096 | 673 | bool lHasAttributes = false; | ||
1097 | 674 | |||
1098 | 675 | lAttrIt = aElement.getAttributes(); | ||
1099 | 676 | lAttrIt->open(); | ||
1100 | 677 | while (lAttrIt->next(lAttr)) | ||
1101 | 678 | { | ||
1102 | 679 | if(lAttr.getNodeKind() == store::StoreConsts::attributeNode) | ||
1103 | 680 | { | ||
1104 | 681 | lHasAttributes = true; | ||
1105 | 682 | break; | ||
1106 | 683 | } | ||
1107 | 684 | } | ||
1108 | 685 | lAttrIt->close(); | ||
1109 | 686 | |||
1110 | 687 | if(lHasAttributes) | ||
1111 | 688 | aResultSs << ",{"; | ||
1112 | 689 | |||
1113 | 690 | bool lFirst = true; | ||
1114 | 691 | lAttrIt = aElement.getAttributes(); | ||
1115 | 692 | lAttrIt->open(); | ||
1116 | 693 | while (lAttrIt->next(lAttr)) | ||
1117 | 694 | { | ||
1118 | 695 | if(lAttr.getNodeKind() == store::StoreConsts::attributeNode) | ||
1119 | 696 | { | ||
1120 | 697 | Item lNodeNameItem; | ||
1121 | 698 | lAttr.getNodeName(lNodeNameItem); | ||
1122 | 699 | if(!lFirst) | ||
1123 | 700 | aResultSs << ","; | ||
1124 | 701 | |||
1125 | 702 | aResultSs << "\"" << lNodeNameItem.getStringValue().c_str() << "\":"; | ||
1126 | 703 | aResultSs << "\"" << lAttr.getStringValue().c_str() << "\""; | ||
1127 | 704 | lFirst = false; | ||
1128 | 705 | } | ||
1129 | 706 | } | ||
1130 | 707 | lAttrIt->close(); | ||
1131 | 708 | if(lHasAttributes) | ||
1132 | 709 | aResultSs << "}"; | ||
1133 | 710 | |||
1134 | 711 | zorba::Iterator_t lChildrenIt; | ||
1135 | 712 | zorba::Item lChild; | ||
1136 | 713 | |||
1137 | 714 | lChildrenIt = aElement.getChildren(); | ||
1138 | 715 | lChildrenIt->open(); | ||
1139 | 716 | while (lChildrenIt->next(lChild)) | ||
1140 | 717 | { | ||
1141 | 718 | aResultSs << ","; | ||
1142 | 719 | if (lChild.getNodeKind() == store::StoreConsts::elementNode || | ||
1143 | 720 | lChild.getNodeKind() == store::StoreConsts::textNode) | ||
1144 | 721 | JSON_ML_serialize(lChild, aResultSs, aErrorLogSs); | ||
1145 | 722 | } | ||
1146 | 723 | lChildrenIt->close(); | ||
1147 | 724 | |||
1148 | 725 | aResultSs << "]"; | ||
1149 | 726 | } | ||
1150 | 727 | |||
1151 | 728 | } /* namespace jsonmodule */ | ||
1152 | 729 | } /* namespace zorba */ | ||
1153 | 730 | 0 | ||
1154 | === removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.h' | |||
1155 | --- src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.h 2011-10-06 07:40:17 +0000 | |||
1156 | +++ src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.h 1970-01-01 00:00:00 +0000 | |||
1157 | @@ -1,56 +0,0 @@ | |||
1158 | 1 | /* | ||
1159 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1160 | 3 | * | ||
1161 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1162 | 5 | * you may not use this file except in compliance with the License. | ||
1163 | 6 | * You may obtain a copy of the License at | ||
1164 | 7 | * | ||
1165 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1166 | 9 | * | ||
1167 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1168 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1169 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1170 | 13 | * See the License for the specific language governing permissions and | ||
1171 | 14 | * limitations under the License. | ||
1172 | 15 | */ | ||
1173 | 16 | |||
1174 | 17 | #ifndef ZORBA_JSONMODULE_JANSSON_WRAPPER_H | ||
1175 | 18 | #define ZORBA_JSONMODULE_JANSSON_WRAPPER_H | ||
1176 | 19 | |||
1177 | 20 | #include <zorba/item_factory.h> | ||
1178 | 21 | #include <zorba/item.h> | ||
1179 | 22 | |||
1180 | 23 | namespace zorba | ||
1181 | 24 | { | ||
1182 | 25 | namespace jsonmodule | ||
1183 | 26 | { | ||
1184 | 27 | //Json parse and serialize: http://www.json.org/ | ||
1185 | 28 | //according to the mapping proposed by john snelson: | ||
1186 | 29 | //http://snelson.org.uk/archives/2008/02/parsing_json_in.php#more | ||
1187 | 30 | void JSON_parse( | ||
1188 | 31 | const char* aJsonString, | ||
1189 | 32 | std::stringstream& aSs, | ||
1190 | 33 | std::stringstream& aErrorLogSs); | ||
1191 | 34 | |||
1192 | 35 | void JSON_serialize( | ||
1193 | 36 | const zorba::Item& aElement, | ||
1194 | 37 | std::stringstream& aResultSs, | ||
1195 | 38 | std::stringstream& aErrorLogSs); | ||
1196 | 39 | |||
1197 | 40 | |||
1198 | 41 | //Json ML parse and serialize: http://jsonml.org/ | ||
1199 | 42 | void JSON_ML_parse( | ||
1200 | 43 | const char* aJsonString, | ||
1201 | 44 | std::stringstream& aSs, | ||
1202 | 45 | std::stringstream& aErrorLogSs); | ||
1203 | 46 | |||
1204 | 47 | |||
1205 | 48 | void JSON_ML_serialize( | ||
1206 | 49 | const zorba::Item& aElement, | ||
1207 | 50 | std::stringstream& aResultSs, | ||
1208 | 51 | std::stringstream& aErrorLogSs); | ||
1209 | 52 | |||
1210 | 53 | } /* namespace jsonmodule */ | ||
1211 | 54 | } /* namespace zorba */ | ||
1212 | 55 | |||
1213 | 56 | #endif //ZORBA_JSONMODULE_JANSSON_WRAPPER_H | ||
1214 | 57 | \ No newline at end of file | 0 | \ No newline at end of file |
1215 | 58 | 1 | ||
1216 | === removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/json.cpp' | |||
1217 | --- src/com/zorba-xquery/www/modules/converters/json.xq.src/json.cpp 2011-08-18 22:09:48 +0000 | |||
1218 | +++ src/com/zorba-xquery/www/modules/converters/json.xq.src/json.cpp 1970-01-01 00:00:00 +0000 | |||
1219 | @@ -1,317 +0,0 @@ | |||
1220 | 1 | /* | ||
1221 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1222 | 3 | * | ||
1223 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1224 | 5 | * you may not use this file except in compliance with the License. | ||
1225 | 6 | * You may obtain a copy of the License at | ||
1226 | 7 | * | ||
1227 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1228 | 9 | * | ||
1229 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1230 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1231 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1232 | 13 | * See the License for the specific language governing permissions and | ||
1233 | 14 | * limitations under the License. | ||
1234 | 15 | */ | ||
1235 | 16 | |||
1236 | 17 | #include <sstream> | ||
1237 | 18 | #include <cassert> | ||
1238 | 19 | |||
1239 | 20 | #include <zorba/empty_sequence.h> | ||
1240 | 21 | #include <zorba/singleton_item_sequence.h> | ||
1241 | 22 | #include <zorba/diagnostic_list.h> | ||
1242 | 23 | #include <zorba/user_exception.h> | ||
1243 | 24 | #include <zorba/item.h> | ||
1244 | 25 | #include <zorba/store_consts.h> | ||
1245 | 26 | |||
1246 | 27 | #include "json.h" | ||
1247 | 28 | #include "jansson_wrapper.h" | ||
1248 | 29 | |||
1249 | 30 | namespace zorba | ||
1250 | 31 | { | ||
1251 | 32 | namespace jsonmodule | ||
1252 | 33 | { | ||
1253 | 34 | zorba::String | ||
1254 | 35 | JsonFunction::getOptionValue(zorba::Item& aOptionsItem, const char* aOptionName) const | ||
1255 | 36 | { | ||
1256 | 37 | zorba::Iterator_t lChildrenIt, lAttrIt; | ||
1257 | 38 | zorba::Item lChild, lAttr, lNodeNameItem; | ||
1258 | 39 | bool lCorrectChild = false; | ||
1259 | 40 | |||
1260 | 41 | lChildrenIt = aOptionsItem.getChildren(); | ||
1261 | 42 | lChildrenIt->open(); | ||
1262 | 43 | while (lChildrenIt->next(lChild)) | ||
1263 | 44 | { | ||
1264 | 45 | if (lChild.getNodeKind() == store::StoreConsts::elementNode) | ||
1265 | 46 | { | ||
1266 | 47 | lAttrIt = lChild.getAttributes(); | ||
1267 | 48 | lAttrIt->open(); | ||
1268 | 49 | while (lAttrIt->next(lAttr)) | ||
1269 | 50 | { | ||
1270 | 51 | if(lAttr.getNodeKind() == store::StoreConsts::attributeNode) | ||
1271 | 52 | { | ||
1272 | 53 | lAttr.getNodeName(lNodeNameItem); | ||
1273 | 54 | if(!lCorrectChild && | ||
1274 | 55 | lNodeNameItem.getStringValue() == "name") | ||
1275 | 56 | lCorrectChild = lAttr.getStringValue() == "mapping"; | ||
1276 | 57 | else if(lCorrectChild && | ||
1277 | 58 | lNodeNameItem.getStringValue() == "value") | ||
1278 | 59 | return lAttr.getStringValue(); | ||
1279 | 60 | } | ||
1280 | 61 | } | ||
1281 | 62 | } | ||
1282 | 63 | } | ||
1283 | 64 | lChildrenIt->close(); | ||
1284 | 65 | |||
1285 | 66 | return zorba::String(""); | ||
1286 | 67 | } | ||
1287 | 68 | //***************************************************************************** | ||
1288 | 69 | //***************************************************************************** | ||
1289 | 70 | |||
1290 | 71 | ParseFunction::ParseFunction(const JsonModule* aModule) | ||
1291 | 72 | : JsonFunction(aModule) | ||
1292 | 73 | { | ||
1293 | 74 | } | ||
1294 | 75 | |||
1295 | 76 | ItemSequence_t | ||
1296 | 77 | ParseFunction::evaluate( | ||
1297 | 78 | const ExternalFunction::Arguments_t& aArgs, | ||
1298 | 79 | const StaticContext* aSctxCtx, | ||
1299 | 80 | const DynamicContext* aDynCtx) const | ||
1300 | 81 | { | ||
1301 | 82 | zorba::Item lStringItem, lOptionsItem, lResItem; | ||
1302 | 83 | zorba::String lBaseUri, lJsonMapping, lOptionName("mapping"); | ||
1303 | 84 | std::stringstream lSs, lErrorLogSs; | ||
1304 | 85 | |||
1305 | 86 | if (aArgs.size() >= 1) | ||
1306 | 87 | { | ||
1307 | 88 | Iterator_t lArg0Iter = aArgs[0]->getIterator(); | ||
1308 | 89 | lArg0Iter->open(); | ||
1309 | 90 | lArg0Iter->next(lStringItem); | ||
1310 | 91 | lArg0Iter->close(); | ||
1311 | 92 | } | ||
1312 | 93 | |||
1313 | 94 | lBaseUri = aSctxCtx->getBaseURI(); | ||
1314 | 95 | |||
1315 | 96 | if (aArgs.size() == 2) | ||
1316 | 97 | { | ||
1317 | 98 | Iterator_t lArg0Iter = aArgs[1]->getIterator(); | ||
1318 | 99 | lArg0Iter->open(); | ||
1319 | 100 | lArg0Iter->next(lOptionsItem); | ||
1320 | 101 | lArg0Iter->close(); | ||
1321 | 102 | } | ||
1322 | 103 | |||
1323 | 104 | lJsonMapping = getOptionValue(lOptionsItem, lOptionName.c_str()); | ||
1324 | 105 | |||
1325 | 106 | if(lJsonMapping == "simple-json") | ||
1326 | 107 | { | ||
1327 | 108 | JSON_parse(lStringItem.getStringValue().c_str(), lSs, lErrorLogSs); | ||
1328 | 109 | } | ||
1329 | 110 | else // if(lJsonMapping == "json-ml") | ||
1330 | 111 | { | ||
1331 | 112 | assert(lJsonMapping == "json-ml"); // the schema makes sure that this is the case | ||
1332 | 113 | JSON_ML_parse(lStringItem.getStringValue().c_str(), lSs, lErrorLogSs); | ||
1333 | 114 | } | ||
1334 | 115 | |||
1335 | 116 | if(!lErrorLogSs.str().empty()) | ||
1336 | 117 | { | ||
1337 | 118 | zorba::Item lError = theModule->getItemFactory()->createQName(theModule->getURI(), "ParseError"); | ||
1338 | 119 | throw USER_EXCEPTION(lError, lErrorLogSs.str()); | ||
1339 | 120 | } | ||
1340 | 121 | |||
1341 | 122 | XmlDataManager* lDataManager = Zorba::getInstance(0)->getXmlDataManager(); | ||
1342 | 123 | Item lItem = lDataManager->parseXML(lSs); | ||
1343 | 124 | |||
1344 | 125 | return ItemSequence_t(new SingletonItemSequence(lItem)); | ||
1345 | 126 | } | ||
1346 | 127 | |||
1347 | 128 | //***************************************************************************** | ||
1348 | 129 | //***************************************************************************** | ||
1349 | 130 | SerializeFunction::StringStreamSequence::StringStreamSequence(ItemSequence* input) | ||
1350 | 131 | : input_iter(input->getIterator()), | ||
1351 | 132 | is(new std::istream(this)) | ||
1352 | 133 | { | ||
1353 | 134 | line_index = 0; | ||
1354 | 135 | has_next = true; | ||
1355 | 136 | is_open = false; | ||
1356 | 137 | open_count = 0; | ||
1357 | 138 | input_iter->open(); | ||
1358 | 139 | } | ||
1359 | 140 | |||
1360 | 141 | void SerializeFunction::StringStreamSequence::open() | ||
1361 | 142 | { | ||
1362 | 143 | is_open = true; | ||
1363 | 144 | line_index = 1; | ||
1364 | 145 | if(open_count) | ||
1365 | 146 | { | ||
1366 | 147 | is->seekg(0); | ||
1367 | 148 | if(is->fail()) | ||
1368 | 149 | throw USER_EXCEPTION(theFactory->createQName( | ||
1369 | 150 | "http://www.zorba-xquery.com/modules/converters/json", | ||
1370 | 151 | "InvalidStream"), | ||
1371 | 152 | "Cannot reset streamable string item"); | ||
1372 | 153 | } | ||
1373 | 154 | open_count++; | ||
1374 | 155 | } | ||
1375 | 156 | |||
1376 | 157 | void SerializeFunction::StringStreamSequence::close() | ||
1377 | 158 | { | ||
1378 | 159 | is_open = false; | ||
1379 | 160 | } | ||
1380 | 161 | |||
1381 | 162 | bool SerializeFunction::StringStreamSequence::isOpen() const | ||
1382 | 163 | { | ||
1383 | 164 | return is_open; | ||
1384 | 165 | } | ||
1385 | 166 | |||
1386 | 167 | bool SerializeFunction::StringStreamSequence::next( Item &result ) | ||
1387 | 168 | { | ||
1388 | 169 | assert(is_open); | ||
1389 | 170 | |||
1390 | 171 | if(!has_next) | ||
1391 | 172 | return false; | ||
1392 | 173 | result = streamable_item; | ||
1393 | 174 | has_next = false; | ||
1394 | 175 | return true; | ||
1395 | 176 | } | ||
1396 | 177 | |||
1397 | 178 | bool SerializeFunction::StringStreamSequence::next(std::string &result_string) | ||
1398 | 179 | { | ||
1399 | 180 | if(!input_iter->next(node_item)) | ||
1400 | 181 | return false; | ||
1401 | 182 | |||
1402 | 183 | std::stringstream lSs, lErrorLogSs; | ||
1403 | 184 | |||
1404 | 185 | if(theMapping == "simple-json") | ||
1405 | 186 | JSON_serialize(node_item, lSs, lErrorLogSs); | ||
1406 | 187 | else if(theMapping == "json-ml") | ||
1407 | 188 | JSON_ML_serialize(node_item, lSs, lErrorLogSs); | ||
1408 | 189 | |||
1409 | 190 | if(!lErrorLogSs.str().empty()) | ||
1410 | 191 | { | ||
1411 | 192 | throw USER_EXCEPTION( | ||
1412 | 193 | theFactory->createQName( | ||
1413 | 194 | "http://www.zorba-xquery.com/modules/converters/json", | ||
1414 | 195 | "InvalidXDM"), | ||
1415 | 196 | lErrorLogSs.str()); | ||
1416 | 197 | } | ||
1417 | 198 | |||
1418 | 199 | result_string = lSs.str(); | ||
1419 | 200 | return true; | ||
1420 | 201 | } | ||
1421 | 202 | |||
1422 | 203 | bool SerializeFunction::StringStreamSequence::reset() | ||
1423 | 204 | { | ||
1424 | 205 | input_iter->close(); | ||
1425 | 206 | input_iter->open(); | ||
1426 | 207 | return true; | ||
1427 | 208 | } | ||
1428 | 209 | |||
1429 | 210 | |||
1430 | 211 | SerializeFunction::SerializeFunction(const JsonModule* aModule) | ||
1431 | 212 | : JsonFunction(aModule) | ||
1432 | 213 | { | ||
1433 | 214 | } | ||
1434 | 215 | |||
1435 | 216 | ItemSequence_t | ||
1436 | 217 | SerializeFunction::evaluate( | ||
1437 | 218 | const ExternalFunction::Arguments_t& aArgs, | ||
1438 | 219 | const StaticContext* aSctxCtx, | ||
1439 | 220 | const DynamicContext* aDynCtx) const | ||
1440 | 221 | { | ||
1441 | 222 | zorba::Item lOptionsItem, lResItem; | ||
1442 | 223 | zorba::String lBaseUri, lJsonMapping, lOptionName("mapping"); | ||
1443 | 224 | std::stringstream lSs, lErrorLogSs; | ||
1444 | 225 | |||
1445 | 226 | lBaseUri = aSctxCtx->getBaseURI(); | ||
1446 | 227 | |||
1447 | 228 | if (aArgs.size() == 2) | ||
1448 | 229 | { | ||
1449 | 230 | Iterator_t lArg0Iter = aArgs[1]->getIterator(); | ||
1450 | 231 | lArg0Iter->open(); | ||
1451 | 232 | lArg0Iter->next(lOptionsItem); | ||
1452 | 233 | lArg0Iter->close(); | ||
1453 | 234 | } | ||
1454 | 235 | |||
1455 | 236 | lJsonMapping = getOptionValue(lOptionsItem, lOptionName.c_str()); | ||
1456 | 237 | |||
1457 | 238 | if(lJsonMapping != "simple-json" && | ||
1458 | 239 | lJsonMapping != "json-ml") | ||
1459 | 240 | { | ||
1460 | 241 | zorba::Item lError = theModule->getItemFactory()->createQName(theModule->getURI(), "WrongParam"); | ||
1461 | 242 | lErrorLogSs << "Mapping type '" << lJsonMapping << "' not supported.\nPossible values are 'simple-json' or 'json-ml'."; | ||
1462 | 243 | throw USER_EXCEPTION(lError, lErrorLogSs.str()); | ||
1463 | 244 | } | ||
1464 | 245 | |||
1465 | 246 | StringStreamSequence *stream_sequence = new StringStreamSequence((ItemSequence*)aArgs[0]); | ||
1466 | 247 | stream_sequence->theMapping = lJsonMapping; | ||
1467 | 248 | stream_sequence->theFactory = theModule->getItemFactory(); | ||
1468 | 249 | stream_sequence->streamable_item = | ||
1469 | 250 | theModule->getItemFactory()->createStreamableString( | ||
1470 | 251 | *(stream_sequence->is), &StringStreamSequence::releaseStream); | ||
1471 | 252 | |||
1472 | 253 | return ItemSequence_t(stream_sequence); | ||
1473 | 254 | |||
1474 | 255 | } | ||
1475 | 256 | |||
1476 | 257 | //***************************************************************************** | ||
1477 | 258 | //***************************************************************************** | ||
1478 | 259 | |||
1479 | 260 | ItemFactory* JsonModule::theFactory = 0; | ||
1480 | 261 | |||
1481 | 262 | JsonModule::~JsonModule() | ||
1482 | 263 | { | ||
1483 | 264 | for ( FuncMap_t::const_iterator lIter = theFunctions.begin(); | ||
1484 | 265 | lIter != theFunctions.end(); | ||
1485 | 266 | ++lIter) | ||
1486 | 267 | { | ||
1487 | 268 | delete lIter->second; | ||
1488 | 269 | } | ||
1489 | 270 | theFunctions.clear(); | ||
1490 | 271 | } | ||
1491 | 272 | |||
1492 | 273 | ExternalFunction* | ||
1493 | 274 | JsonModule::getExternalFunction(const String& aLocalname) | ||
1494 | 275 | { | ||
1495 | 276 | ExternalFunction*& lFunc = theFunctions[aLocalname]; | ||
1496 | 277 | if (!lFunc) | ||
1497 | 278 | { | ||
1498 | 279 | if (1 == 0) | ||
1499 | 280 | { } | ||
1500 | 281 | else if (aLocalname == "parse-internal") | ||
1501 | 282 | { | ||
1502 | 283 | lFunc = new ParseFunction(this); | ||
1503 | 284 | } | ||
1504 | 285 | else if (aLocalname == "serialize-internal") | ||
1505 | 286 | { | ||
1506 | 287 | lFunc = new SerializeFunction(this); | ||
1507 | 288 | } | ||
1508 | 289 | } | ||
1509 | 290 | return lFunc; | ||
1510 | 291 | } | ||
1511 | 292 | |||
1512 | 293 | void | ||
1513 | 294 | JsonModule::destroy() | ||
1514 | 295 | { | ||
1515 | 296 | if (!dynamic_cast<JsonModule*>(this)) | ||
1516 | 297 | { | ||
1517 | 298 | return; | ||
1518 | 299 | } | ||
1519 | 300 | delete this; | ||
1520 | 301 | } | ||
1521 | 302 | //***************************************************************************** | ||
1522 | 303 | //***************************************************************************** | ||
1523 | 304 | |||
1524 | 305 | } /* namespace jsonmodule */ | ||
1525 | 306 | } /* namespace zorba */ | ||
1526 | 307 | |||
1527 | 308 | #ifdef WIN32 | ||
1528 | 309 | # define DLL_EXPORT __declspec(dllexport) | ||
1529 | 310 | #else | ||
1530 | 311 | # define DLL_EXPORT __attribute__ ((visibility("default"))) | ||
1531 | 312 | #endif | ||
1532 | 313 | |||
1533 | 314 | extern "C" DLL_EXPORT zorba::ExternalModule* createModule() | ||
1534 | 315 | { | ||
1535 | 316 | return new zorba::jsonmodule::JsonModule(); | ||
1536 | 317 | } | ||
1537 | 318 | 0 | ||
1538 | === removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/json.h' | |||
1539 | --- src/com/zorba-xquery/www/modules/converters/json.xq.src/json.h 2011-10-06 07:40:17 +0000 | |||
1540 | +++ src/com/zorba-xquery/www/modules/converters/json.xq.src/json.h 1970-01-01 00:00:00 +0000 | |||
1541 | @@ -1,167 +0,0 @@ | |||
1542 | 1 | /* | ||
1543 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1544 | 3 | * | ||
1545 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1546 | 5 | * you may not use this file except in compliance with the License. | ||
1547 | 6 | * You may obtain a copy of the License at | ||
1548 | 7 | * | ||
1549 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1550 | 9 | * | ||
1551 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1552 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1553 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1554 | 13 | * See the License for the specific language governing permissions and | ||
1555 | 14 | * limitations under the License. | ||
1556 | 15 | */ | ||
1557 | 16 | #ifndef ZORBA_JSONMODULE_JSON_H | ||
1558 | 17 | #define ZORBA_JSONMODULE_JSON_H | ||
1559 | 18 | |||
1560 | 19 | #include <map> | ||
1561 | 20 | |||
1562 | 21 | #include <zorba/zorba.h> | ||
1563 | 22 | #include <zorba/iterator.h> | ||
1564 | 23 | #include <zorba/function.h> | ||
1565 | 24 | #include <zorba/external_module.h> | ||
1566 | 25 | |||
1567 | 26 | #include "stringiterator_streambuf.h" | ||
1568 | 27 | |||
1569 | 28 | namespace zorba | ||
1570 | 29 | { | ||
1571 | 30 | namespace jsonmodule | ||
1572 | 31 | { | ||
1573 | 32 | //***************************************************************************** | ||
1574 | 33 | //***************************************************************************** | ||
1575 | 34 | class JsonModule : public ExternalModule | ||
1576 | 35 | { | ||
1577 | 36 | private: | ||
1578 | 37 | static ItemFactory* theFactory; | ||
1579 | 38 | |||
1580 | 39 | protected: | ||
1581 | 40 | class ltstr | ||
1582 | 41 | { | ||
1583 | 42 | public: | ||
1584 | 43 | bool operator()(const String& s1, const String& s2) const | ||
1585 | 44 | { | ||
1586 | 45 | return s1.compare(s2) < 0; | ||
1587 | 46 | } | ||
1588 | 47 | }; | ||
1589 | 48 | |||
1590 | 49 | typedef std::map<String, ExternalFunction*, ltstr> FuncMap_t; | ||
1591 | 50 | |||
1592 | 51 | FuncMap_t theFunctions; | ||
1593 | 52 | |||
1594 | 53 | public: | ||
1595 | 54 | virtual ~JsonModule(); | ||
1596 | 55 | |||
1597 | 56 | virtual String | ||
1598 | 57 | getURI() const { return "http://www.zorba-xquery.com/modules/converters/json"; } | ||
1599 | 58 | |||
1600 | 59 | virtual ExternalFunction* | ||
1601 | 60 | getExternalFunction(const String& aLocalname); | ||
1602 | 61 | |||
1603 | 62 | virtual void | ||
1604 | 63 | destroy(); | ||
1605 | 64 | |||
1606 | 65 | static ItemFactory* | ||
1607 | 66 | getItemFactory() | ||
1608 | 67 | { | ||
1609 | 68 | if(!theFactory) | ||
1610 | 69 | { | ||
1611 | 70 | theFactory = Zorba::getInstance(0)->getItemFactory(); | ||
1612 | 71 | } | ||
1613 | 72 | return theFactory; | ||
1614 | 73 | } | ||
1615 | 74 | }; | ||
1616 | 75 | |||
1617 | 76 | //***************************************************************************** | ||
1618 | 77 | //***************************************************************************** | ||
1619 | 78 | class JsonFunction : public ContextualExternalFunction | ||
1620 | 79 | { | ||
1621 | 80 | protected: | ||
1622 | 81 | const JsonModule* theModule; | ||
1623 | 82 | zorba::String getOptionValue(zorba::Item& aOptionsItem, const char* aOptionName) const; | ||
1624 | 83 | public: | ||
1625 | 84 | JsonFunction(const JsonModule* aModule) | ||
1626 | 85 | : theModule(aModule) {}; | ||
1627 | 86 | |||
1628 | 87 | ~JsonFunction() {}; | ||
1629 | 88 | |||
1630 | 89 | virtual String | ||
1631 | 90 | getURI() const { return theModule->getURI(); } | ||
1632 | 91 | |||
1633 | 92 | }; | ||
1634 | 93 | |||
1635 | 94 | //***************************************************************************** | ||
1636 | 95 | //***************************************************************************** | ||
1637 | 96 | class ParseFunction : public JsonFunction | ||
1638 | 97 | { | ||
1639 | 98 | public: | ||
1640 | 99 | ParseFunction(const JsonModule* aModule); | ||
1641 | 100 | |||
1642 | 101 | virtual String | ||
1643 | 102 | getLocalName() const { return "parse-internal"; } | ||
1644 | 103 | |||
1645 | 104 | virtual ItemSequence_t | ||
1646 | 105 | evaluate(const ExternalFunction::Arguments_t& args, | ||
1647 | 106 | const StaticContext* aSctxCtx, | ||
1648 | 107 | const DynamicContext* aDynCtx) const; | ||
1649 | 108 | }; | ||
1650 | 109 | |||
1651 | 110 | class SerializeFunction : public JsonFunction | ||
1652 | 111 | { | ||
1653 | 112 | class StringStreamSequence : public ItemSequence, public Iterator, public StringIteratorStreamBuf | ||
1654 | 113 | { | ||
1655 | 114 | private: | ||
1656 | 115 | Iterator_t input_iter; | ||
1657 | 116 | std::vector<std::vector<String> > headers; | ||
1658 | 117 | int line_index; | ||
1659 | 118 | bool has_next; | ||
1660 | 119 | bool is_open; | ||
1661 | 120 | int open_count; | ||
1662 | 121 | |||
1663 | 122 | std::vector<String> line; | ||
1664 | 123 | Item node_item; | ||
1665 | 124 | public: | ||
1666 | 125 | std::istream* is; | ||
1667 | 126 | String theMapping; | ||
1668 | 127 | ItemFactory* theFactory; | ||
1669 | 128 | Item streamable_item; | ||
1670 | 129 | public: | ||
1671 | 130 | StringStreamSequence(ItemSequence* input); | ||
1672 | 131 | virtual ~StringStreamSequence() {} | ||
1673 | 132 | |||
1674 | 133 | //for Iterator | ||
1675 | 134 | virtual void open(); | ||
1676 | 135 | virtual void close(); | ||
1677 | 136 | virtual bool isOpen() const; | ||
1678 | 137 | virtual bool next( Item &result ); | ||
1679 | 138 | |||
1680 | 139 | //for ItemSequence | ||
1681 | 140 | Iterator_t getIterator() {return this;} | ||
1682 | 141 | |||
1683 | 142 | //for StringIteratorStreamBuf | ||
1684 | 143 | virtual bool next(std::string &next_string); | ||
1685 | 144 | virtual bool reset(); | ||
1686 | 145 | |||
1687 | 146 | static void | ||
1688 | 147 | releaseStream(std::istream* stream) { delete stream; } | ||
1689 | 148 | |||
1690 | 149 | }; | ||
1691 | 150 | public: | ||
1692 | 151 | SerializeFunction(const JsonModule* aModule); | ||
1693 | 152 | |||
1694 | 153 | virtual String | ||
1695 | 154 | getLocalName() const { return "serialize-internal"; } | ||
1696 | 155 | |||
1697 | 156 | virtual ItemSequence_t | ||
1698 | 157 | evaluate(const ExternalFunction::Arguments_t& args, | ||
1699 | 158 | const StaticContext* aSctxCtx, | ||
1700 | 159 | const DynamicContext* aDynCtx) const; | ||
1701 | 160 | }; | ||
1702 | 161 | |||
1703 | 162 | |||
1704 | 163 | |||
1705 | 164 | } /* namespace jsonmodule */ | ||
1706 | 165 | } /* namespace zorba */ | ||
1707 | 166 | |||
1708 | 167 | #endif /* ZORBA_JSONMODULE_JSON_H */ | ||
1709 | 168 | 0 | ||
1710 | === removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.cpp' | |||
1711 | --- src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.cpp 2011-07-13 01:57:10 +0000 | |||
1712 | +++ src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.cpp 1970-01-01 00:00:00 +0000 | |||
1713 | @@ -1,153 +0,0 @@ | |||
1714 | 1 | /* | ||
1715 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1716 | 3 | * | ||
1717 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1718 | 5 | * you may not use this file except in compliance with the License. | ||
1719 | 6 | * You may obtain a copy of the License at | ||
1720 | 7 | * | ||
1721 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1722 | 9 | * | ||
1723 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1724 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1725 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1726 | 13 | * See the License for the specific language governing permissions and | ||
1727 | 14 | * limitations under the License. | ||
1728 | 15 | */ | ||
1729 | 16 | |||
1730 | 17 | #include <zorba/diagnostic_list.h> | ||
1731 | 18 | |||
1732 | 19 | #include "stringiterator_streambuf.h" | ||
1733 | 20 | |||
1734 | 21 | using namespace std; | ||
1735 | 22 | namespace zorba{ | ||
1736 | 23 | |||
1737 | 24 | StringIteratorStreamBuf::StringIteratorStreamBuf() | ||
1738 | 25 | { | ||
1739 | 26 | current_buffer = 0; | ||
1740 | 27 | last_buffer = 0; | ||
1741 | 28 | begin_offset = 0; | ||
1742 | 29 | is_eof = false; | ||
1743 | 30 | } | ||
1744 | 31 | |||
1745 | 32 | //get next buffer | ||
1746 | 33 | int StringIteratorStreamBuf::underflow() | ||
1747 | 34 | { | ||
1748 | 35 | if(is_eof) | ||
1749 | 36 | return EOF; | ||
1750 | 37 | |||
1751 | 38 | begin_offset += buffer[current_buffer].length(); | ||
1752 | 39 | current_buffer = 1 - current_buffer; | ||
1753 | 40 | if(last_buffer != current_buffer) | ||
1754 | 41 | { | ||
1755 | 42 | buffer[current_buffer].resize(0); | ||
1756 | 43 | last_buffer = current_buffer; | ||
1757 | 44 | if(!next(buffer[current_buffer])) | ||
1758 | 45 | { | ||
1759 | 46 | //current_buffer = 1 - current_buffer; | ||
1760 | 47 | buffer[current_buffer].resize(0); | ||
1761 | 48 | is_eof = true; | ||
1762 | 49 | return EOF; | ||
1763 | 50 | } | ||
1764 | 51 | } | ||
1765 | 52 | |||
1766 | 53 | char *buffstr = (char*)buffer[current_buffer].c_str(); | ||
1767 | 54 | setg(buffstr, buffstr, buffstr+buffer[current_buffer].length()); | ||
1768 | 55 | return *buffstr; | ||
1769 | 56 | } | ||
1770 | 57 | |||
1771 | 58 | //unget char, some special cases | ||
1772 | 59 | int StringIteratorStreamBuf::pbackfail ( int c ) | ||
1773 | 60 | { | ||
1774 | 61 | if(eback() != gptr()) | ||
1775 | 62 | { | ||
1776 | 63 | setg(eback(), gptr()-1, egptr()); | ||
1777 | 64 | if(c != EOF) | ||
1778 | 65 | *gptr() = (char)c; | ||
1779 | 66 | return 1; | ||
1780 | 67 | } | ||
1781 | 68 | |||
1782 | 69 | //else have to rewind to previous buffer | ||
1783 | 70 | if(last_buffer != current_buffer) | ||
1784 | 71 | return EOF; | ||
1785 | 72 | if(buffer[1-last_buffer].length() == 0) | ||
1786 | 73 | return EOF; | ||
1787 | 74 | current_buffer = 1 - current_buffer; | ||
1788 | 75 | |||
1789 | 76 | begin_offset -= buffer[current_buffer].length(); | ||
1790 | 77 | char *buffstr = (char*)buffer[current_buffer].c_str(); | ||
1791 | 78 | setg(buffstr, buffstr+buffer[current_buffer].length()-1, buffstr+buffer[current_buffer].length()); | ||
1792 | 79 | if(c != EOF) | ||
1793 | 80 | *gptr() = (char)c; | ||
1794 | 81 | return 1; | ||
1795 | 82 | } | ||
1796 | 83 | |||
1797 | 84 | //set a new position | ||
1798 | 85 | //if going too much back, restart the iterator | ||
1799 | 86 | streampos StringIteratorStreamBuf::seekoff ( streamoff off, ios_base::seekdir way, ios_base::openmode which ) | ||
1800 | 87 | { | ||
1801 | 88 | if(!(which & ios_base::in)) | ||
1802 | 89 | return -1; | ||
1803 | 90 | |||
1804 | 91 | streampos targetpos; | ||
1805 | 92 | if(way == ios_base::end) | ||
1806 | 93 | { | ||
1807 | 94 | if(off > 0) | ||
1808 | 95 | return -1; | ||
1809 | 96 | while(underflow() != EOF); | ||
1810 | 97 | streampos maxpos = begin_offset + (streamoff)buffer[current_buffer].length(); | ||
1811 | 98 | targetpos = maxpos + off; | ||
1812 | 99 | } | ||
1813 | 100 | else if(way == ios_base::cur) | ||
1814 | 101 | { | ||
1815 | 102 | targetpos = begin_offset + (streamoff)(gptr() - eback()) + off; | ||
1816 | 103 | } | ||
1817 | 104 | else if(way == ios_base::beg) | ||
1818 | 105 | { | ||
1819 | 106 | if(off < 0) | ||
1820 | 107 | return -1; | ||
1821 | 108 | targetpos = off; | ||
1822 | 109 | } | ||
1823 | 110 | else | ||
1824 | 111 | return -1; | ||
1825 | 112 | return seekpos(targetpos, ios_base::in); | ||
1826 | 113 | } | ||
1827 | 114 | |||
1828 | 115 | //set a new position | ||
1829 | 116 | //if going too much back, restart the iterator | ||
1830 | 117 | streampos StringIteratorStreamBuf::seekpos ( streampos sp, ios_base::openmode which ) | ||
1831 | 118 | { | ||
1832 | 119 | if(!(which & ios_base::in)) | ||
1833 | 120 | return -1; | ||
1834 | 121 | |||
1835 | 122 | if(sp < begin_offset) | ||
1836 | 123 | { | ||
1837 | 124 | setg(eback(), eback(), egptr()); | ||
1838 | 125 | pbackfail(EOF); | ||
1839 | 126 | if(sp < begin_offset) | ||
1840 | 127 | { | ||
1841 | 128 | //restart the iterator | ||
1842 | 129 | if(!reset()) | ||
1843 | 130 | return -1; | ||
1844 | 131 | buffer[0].resize(0); | ||
1845 | 132 | buffer[1].resize(0); | ||
1846 | 133 | current_buffer = last_buffer = 0; | ||
1847 | 134 | begin_offset = 0; | ||
1848 | 135 | is_eof = false; | ||
1849 | 136 | setg(NULL, NULL, NULL); | ||
1850 | 137 | } | ||
1851 | 138 | } | ||
1852 | 139 | while(sp >= (begin_offset+(streamoff)buffer[current_buffer].length())) | ||
1853 | 140 | { | ||
1854 | 141 | if(underflow() == EOF) | ||
1855 | 142 | { | ||
1856 | 143 | if(sp == (begin_offset+(streamoff)buffer[current_buffer].length())) | ||
1857 | 144 | break; | ||
1858 | 145 | return -1; | ||
1859 | 146 | } | ||
1860 | 147 | } | ||
1861 | 148 | |||
1862 | 149 | setg(eback(), eback() + (streamoff)(sp - begin_offset), egptr()); | ||
1863 | 150 | return sp; | ||
1864 | 151 | } | ||
1865 | 152 | |||
1866 | 153 | } | ||
1867 | 154 | 0 | ||
1868 | === removed file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.h' | |||
1869 | --- src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.h 2011-10-06 07:40:17 +0000 | |||
1870 | +++ src/com/zorba-xquery/www/modules/converters/json.xq.src/stringiterator_streambuf.h 1970-01-01 00:00:00 +0000 | |||
1871 | @@ -1,49 +0,0 @@ | |||
1872 | 1 | /* | ||
1873 | 2 | * Copyright 2006-2008 The FLWOR Foundation. | ||
1874 | 3 | * | ||
1875 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
1876 | 5 | * you may not use this file except in compliance with the License. | ||
1877 | 6 | * You may obtain a copy of the License at | ||
1878 | 7 | * | ||
1879 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
1880 | 9 | * | ||
1881 | 10 | * Unless required by applicable law or agreed to in writing, software | ||
1882 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
1883 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
1884 | 13 | * See the License for the specific language governing permissions and | ||
1885 | 14 | * limitations under the License. | ||
1886 | 15 | */ | ||
1887 | 16 | |||
1888 | 17 | #include <stdio.h> | ||
1889 | 18 | #include <streambuf> | ||
1890 | 19 | #include <istream> | ||
1891 | 20 | |||
1892 | 21 | #ifndef STRING_ITERATOR_TO_STREAMBUF_IMPL | ||
1893 | 22 | #define STRING_ITERATOR_TO_STREAMBUF_IMPL | ||
1894 | 23 | |||
1895 | 24 | namespace zorba{ | ||
1896 | 25 | |||
1897 | 26 | class StringIteratorStreamBuf : public std::streambuf | ||
1898 | 27 | { | ||
1899 | 28 | std::string buffer[2]; | ||
1900 | 29 | int current_buffer; | ||
1901 | 30 | int last_buffer; | ||
1902 | 31 | std::streampos begin_offset; | ||
1903 | 32 | bool is_eof; | ||
1904 | 33 | public: | ||
1905 | 34 | StringIteratorStreamBuf(); | ||
1906 | 35 | virtual ~StringIteratorStreamBuf() {} | ||
1907 | 36 | |||
1908 | 37 | virtual int underflow ( ); | ||
1909 | 38 | virtual int pbackfail ( int c = EOF ); | ||
1910 | 39 | |||
1911 | 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 ); | ||
1912 | 41 | virtual std::streampos seekpos ( std::streampos sp, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out ); | ||
1913 | 42 | |||
1914 | 43 | public: | ||
1915 | 44 | virtual bool next(std::string &next_string) = 0; | ||
1916 | 45 | virtual bool reset() = 0; | ||
1917 | 46 | }; | ||
1918 | 47 | |||
1919 | 48 | } | ||
1920 | 49 | #endif | ||
1921 | 50 | 0 | ||
1922 | === removed directory 'test_json' | |||
1923 | === removed directory 'test_json/ExpQueryResults' | |||
1924 | === removed directory 'test_json/ExpQueryResults/converters' | |||
1925 | === removed directory 'test_json/ExpQueryResults/converters/jansson' | |||
1926 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_01.xml.res' | |||
1927 | --- test_json/ExpQueryResults/converters/jansson/parse_json_01.xml.res 2011-05-31 15:21:09 +0000 | |||
1928 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_01.xml.res 1970-01-01 00:00:00 +0000 | |||
1929 | @@ -1,1 +0,0 @@ | |||
1930 | 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> | ||
1931 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1932 | 3 | 1 | ||
1933 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_02.xml.res' | |||
1934 | --- test_json/ExpQueryResults/converters/jansson/parse_json_02.xml.res 2011-05-31 15:21:09 +0000 | |||
1935 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_02.xml.res 1970-01-01 00:00:00 +0000 | |||
1936 | @@ -1,1 +0,0 @@ | |||
1937 | 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> | ||
1938 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1939 | 3 | 1 | ||
1940 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_03.xml.res' | |||
1941 | --- test_json/ExpQueryResults/converters/jansson/parse_json_03.xml.res 2011-05-31 15:21:09 +0000 | |||
1942 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_03.xml.res 1970-01-01 00:00:00 +0000 | |||
1943 | @@ -1,1 +0,0 @@ | |||
1944 | 1 | <json type="object"><pair name="mdash" type="string">–</pair></json> | ||
1945 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1946 | 3 | 1 | ||
1947 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_06.xml.res' | |||
1948 | --- test_json/ExpQueryResults/converters/jansson/parse_json_06.xml.res 2011-05-31 15:21:09 +0000 | |||
1949 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_06.xml.res 1970-01-01 00:00:00 +0000 | |||
1950 | @@ -1,1 +0,0 @@ | |||
1951 | 1 | <json type="object"><pair name="web-app" type="string">!_\\"-\\?*.$+</pair></json> | ||
1952 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1953 | 3 | 1 | ||
1954 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_07.xml.res' | |||
1955 | --- test_json/ExpQueryResults/converters/jansson/parse_json_07.xml.res 2011-05-31 15:21:09 +0000 | |||
1956 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_07.xml.res 1970-01-01 00:00:00 +0000 | |||
1957 | @@ -1,1 +0,0 @@ | |||
1958 | 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> | ||
1959 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1960 | 3 | 1 | ||
1961 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_08.xml.res' | |||
1962 | --- test_json/ExpQueryResults/converters/jansson/parse_json_08.xml.res 2011-05-31 15:21:09 +0000 | |||
1963 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_08.xml.res 1970-01-01 00:00:00 +0000 | |||
1964 | @@ -1,1 +0,0 @@ | |||
1965 | 1 | <json type="object"><pair name="web-app" type="null"/></json> | ||
1966 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1967 | 3 | 1 | ||
1968 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_09.xml.res' | |||
1969 | --- test_json/ExpQueryResults/converters/jansson/parse_json_09.xml.res 2011-05-31 15:21:09 +0000 | |||
1970 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_09.xml.res 1970-01-01 00:00:00 +0000 | |||
1971 | @@ -1,1 +0,0 @@ | |||
1972 | 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> | ||
1973 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1974 | 3 | 1 | ||
1975 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_10.xml.res' | |||
1976 | --- test_json/ExpQueryResults/converters/jansson/parse_json_10.xml.res 2011-05-31 15:21:09 +0000 | |||
1977 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_10.xml.res 1970-01-01 00:00:00 +0000 | |||
1978 | @@ -1,1 +0,0 @@ | |||
1979 | 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> | ||
1980 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1981 | 3 | 1 | ||
1982 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_11.xml.res' | |||
1983 | --- test_json/ExpQueryResults/converters/jansson/parse_json_11.xml.res 2011-05-31 15:21:09 +0000 | |||
1984 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_11.xml.res 1970-01-01 00:00:00 +0000 | |||
1985 | @@ -1,1 +0,0 @@ | |||
1986 | 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> | ||
1987 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
1988 | 3 | 1 | ||
1989 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res' | |||
1990 | --- test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res 2011-12-06 14:20:24 +0000 | |||
1991 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res 1970-01-01 00:00:00 +0000 | |||
1992 | @@ -1,1 +0,0 @@ | |||
1993 | 1 | {"html": "<b>bold<\/b>"} | ||
1994 | 2 | 0 | ||
1995 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_01.xml.res' | |||
1996 | --- test_json/ExpQueryResults/converters/jansson/parse_json_ml_01.xml.res 2011-05-31 15:21:09 +0000 | |||
1997 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_01.xml.res 1970-01-01 00:00:00 +0000 | |||
1998 | @@ -1,1 +0,0 @@ | |||
1999 | 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> | ||
2000 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2001 | 3 | 1 | ||
2002 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_02.xml.res' | |||
2003 | --- test_json/ExpQueryResults/converters/jansson/parse_json_ml_02.xml.res 2011-05-31 15:21:09 +0000 | |||
2004 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_02.xml.res 1970-01-01 00:00:00 +0000 | |||
2005 | @@ -1,1 +0,0 @@ | |||
2006 | 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> | ||
2007 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2008 | 3 | 1 | ||
2009 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_05.xml.res' | |||
2010 | --- test_json/ExpQueryResults/converters/jansson/parse_json_ml_05.xml.res 2011-05-31 15:21:09 +0000 | |||
2011 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_05.xml.res 1970-01-01 00:00:00 +0000 | |||
2012 | @@ -1,1 +0,0 @@ | |||
2013 | 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> | ||
2014 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2015 | 3 | 1 | ||
2016 | === removed file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res' | |||
2017 | --- test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res 2011-12-06 14:20:24 +0000 | |||
2018 | +++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res 1970-01-01 00:00:00 +0000 | |||
2019 | @@ -1,1 +0,0 @@ | |||
2020 | 1 | <html><b>bold</b></html> | ||
2021 | 2 | 0 | ||
2022 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_01.xml.res' | |||
2023 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_01.xml.res 2011-12-07 18:44:46 +0000 | |||
2024 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_01.xml.res 1970-01-01 00:00:00 +0000 | |||
2025 | @@ -1,1 +0,0 @@ | |||
2026 | 1 | {"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}} | ||
2027 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2028 | 3 | 1 | ||
2029 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_02.xml.res' | |||
2030 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_02.xml.res 2011-12-07 18:44:46 +0000 | |||
2031 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_02.xml.res 1970-01-01 00:00:00 +0000 | |||
2032 | @@ -1,1 +0,0 @@ | |||
2033 | 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"}}] | ||
2034 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2035 | 3 | 1 | ||
2036 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_04.xml.res' | |||
2037 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_04.xml.res 2011-12-07 18:44:46 +0000 | |||
2038 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_04.xml.res 1970-01-01 00:00:00 +0000 | |||
2039 | @@ -1,1 +0,0 @@ | |||
2040 | 1 | {"firstName": "\""} | ||
2041 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2042 | 3 | 1 | ||
2043 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_05.xml.res' | |||
2044 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_05.xml.res 2011-12-07 18:44:46 +0000 | |||
2045 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_05.xml.res 1970-01-01 00:00:00 +0000 | |||
2046 | @@ -1,1 +0,0 @@ | |||
2047 | 1 | {"name": "\"\\\/\b\f\n\r\t"} | ||
2048 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2049 | 3 | 1 | ||
2050 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_09.xml.res' | |||
2051 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_09.xml.res 2011-12-07 18:44:46 +0000 | |||
2052 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_09.xml.res 1970-01-01 00:00:00 +0000 | |||
2053 | @@ -1,1 +0,0 @@ | |||
2054 | 1 | {"servlet": [["value1"], "value2"]} | ||
2055 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2056 | 3 | 1 | ||
2057 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_10.xml.res' | |||
2058 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_10.xml.res 2011-05-31 15:21:09 +0000 | |||
2059 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_10.xml.res 1970-01-01 00:00:00 +0000 | |||
2060 | @@ -1,1 +0,0 @@ | |||
2061 | 1 | {"servlet": [{"name": "value1"}, "value2"] | ||
2062 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2063 | 3 | 1 | ||
2064 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_13.xml.res' | |||
2065 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_13.xml.res 2011-12-07 18:44:46 +0000 | |||
2066 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_13.xml.res 1970-01-01 00:00:00 +0000 | |||
2067 | @@ -1,1 +0,0 @@ | |||
2068 | 1 | {"servlet": ["value"]} | ||
2069 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2070 | 3 | 1 | ||
2071 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_14.xml.res' | |||
2072 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_14.xml.res 2011-12-07 18:44:46 +0000 | |||
2073 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_14.xml.res 1970-01-01 00:00:00 +0000 | |||
2074 | @@ -1,1 +0,0 @@ | |||
2075 | 1 | {"servlet": {"name": "value"}} | ||
2076 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2077 | 3 | 1 | ||
2078 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_15.xml.res' | |||
2079 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_15.xml.res 2011-12-07 18:44:46 +0000 | |||
2080 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_15.xml.res 1970-01-01 00:00:00 +0000 | |||
2081 | @@ -1,1 +0,0 @@ | |||
2082 | 1 | {"servlet": [{}]} | ||
2083 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2084 | 3 | 1 | ||
2085 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_16.xml.res' | |||
2086 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_16.xml.res 2011-12-07 18:44:46 +0000 | |||
2087 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_16.xml.res 1970-01-01 00:00:00 +0000 | |||
2088 | @@ -1,1 +0,0 @@ | |||
2089 | 1 | {"servlet": [["212 732-1234"]]} | ||
2090 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2091 | 3 | 1 | ||
2092 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_17.xml.res' | |||
2093 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_17.xml.res 2011-05-31 15:21:09 +0000 | |||
2094 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_17.xml.res 1970-01-01 00:00:00 +0000 | |||
2095 | @@ -1,1 +0,0 @@ | |||
2096 | 1 | {"special-chars": {"backslash": "\\", "formfeed": "\f", "quote": "\\"", "horizontal tab": "\t", "carriage return": "\r", "backspace": "\b", "newline": "\n", "solidus": "\/"}} | ||
2097 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2098 | 3 | 1 | ||
2099 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_18.xml.res' | |||
2100 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_18.xml.res 2011-12-05 20:05:44 +0000 | |||
2101 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_18.xml.res 1970-01-01 00:00:00 +0000 | |||
2102 | @@ -1,1 +0,0 @@ | |||
2103 | 1 | {"phoneNumbers": ["212 732-1234", "646 123-4567"], "firstName": "John", "lastName": "Smith", "address": {"postalCode": 10021, "city": "New York", "streetAddress": "21 2nd Street", "state": "NY"}} | ||
2104 | 2 | 0 | ||
2105 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_ml_01.xml.res' | |||
2106 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_ml_01.xml.res 2011-05-31 15:21:09 +0000 | |||
2107 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_ml_01.xml.res 1970-01-01 00:00:00 +0000 | |||
2108 | @@ -1,1 +0,0 @@ | |||
2109 | 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"]] | ||
2110 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2111 | 3 | 1 | ||
2112 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_ml_02.xml.res' | |||
2113 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_ml_02.xml.res 2011-05-31 15:21:09 +0000 | |||
2114 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_ml_02.xml.res 1970-01-01 00:00:00 +0000 | |||
2115 | @@ -1,1 +0,0 @@ | |||
2116 | 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"]]] | ||
2117 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2118 | 3 | 1 | ||
2119 | === removed file 'test_json/ExpQueryResults/converters/jansson/serialize_json_ml_04.xml.res' | |||
2120 | --- test_json/ExpQueryResults/converters/jansson/serialize_json_ml_04.xml.res 2011-05-31 15:21:09 +0000 | |||
2121 | +++ test_json/ExpQueryResults/converters/jansson/serialize_json_ml_04.xml.res 1970-01-01 00:00:00 +0000 | |||
2122 | @@ -1,1 +0,0 @@ | |||
2123 | 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"]] | ||
2124 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2125 | 3 | 1 | ||
2126 | === removed directory 'test_json/Queries' | |||
2127 | === removed directory 'test_json/Queries/converters' | |||
2128 | === removed directory 'test_json/Queries/converters/jansson' | |||
2129 | === removed file 'test_json/Queries/converters/jansson/parse_json_01.spec' | |||
2130 | --- test_json/Queries/converters/jansson/parse_json_01.spec 2011-05-31 15:21:09 +0000 | |||
2131 | +++ test_json/Queries/converters/jansson/parse_json_01.spec 1970-01-01 00:00:00 +0000 | |||
2132 | @@ -1,1 +0,0 @@ | |||
2133 | 1 | Comparison: Ignore | ||
2134 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2135 | 3 | 1 | ||
2136 | === removed file 'test_json/Queries/converters/jansson/parse_json_01.xq' | |||
2137 | --- test_json/Queries/converters/jansson/parse_json_01.xq 2011-08-07 21:55:48 +0000 | |||
2138 | +++ test_json/Queries/converters/jansson/parse_json_01.xq 1970-01-01 00:00:00 +0000 | |||
2139 | @@ -1,22 +0,0 @@ | |||
2140 | 1 | (: the comparison method for this test is set to Ignore because the order in which the children | ||
2141 | 2 | are returned in jansson 1.2, 1.3, 2.0 is different:) | ||
2142 | 3 | |||
2143 | 4 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2144 | 5 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2145 | 6 | |||
2146 | 7 | json:parse(('{ | ||
2147 | 8 | "firstName": "John", | ||
2148 | 9 | "lastName": "Smith", | ||
2149 | 10 | "address": { | ||
2150 | 11 | "streetAddress": "21 2nd Street", | ||
2151 | 12 | "city": "New York", | ||
2152 | 13 | "state": "NY", | ||
2153 | 14 | "postalCode": 10021 | ||
2154 | 15 | }, | ||
2155 | 16 | "phoneNumbers": [ | ||
2156 | 17 | "212 732-1234", | ||
2157 | 18 | "646 123-4567" | ||
2158 | 19 | ] | ||
2159 | 20 | }'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2160 | 21 | <json-param name="mapping" value="simple-json" /> | ||
2161 | 22 | </options>) | ||
2162 | 23 | 0 | ||
2163 | === removed file 'test_json/Queries/converters/jansson/parse_json_02.spec' | |||
2164 | --- test_json/Queries/converters/jansson/parse_json_02.spec 2011-05-31 15:21:09 +0000 | |||
2165 | +++ test_json/Queries/converters/jansson/parse_json_02.spec 1970-01-01 00:00:00 +0000 | |||
2166 | @@ -1,1 +0,0 @@ | |||
2167 | 1 | Comparison: Ignore | ||
2168 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2169 | 3 | 1 | ||
2170 | === removed file 'test_json/Queries/converters/jansson/parse_json_02.xq' | |||
2171 | --- test_json/Queries/converters/jansson/parse_json_02.xq 2011-08-07 21:55:48 +0000 | |||
2172 | +++ test_json/Queries/converters/jansson/parse_json_02.xq 1970-01-01 00:00:00 +0000 | |||
2173 | @@ -1,37 +0,0 @@ | |||
2174 | 1 | (: the comparison method for this test is set to Ignore because the order in which the children | ||
2175 | 2 | are returned in jansson 1.2, 1.3, 2.0 is different:) | ||
2176 | 3 | |||
2177 | 4 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2178 | 5 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2179 | 6 | |||
2180 | 7 | json:parse(('[ | ||
2181 | 8 | { | ||
2182 | 9 | "firstName": "John", | ||
2183 | 10 | "lastName": "Smith", | ||
2184 | 11 | "address": { | ||
2185 | 12 | "streetAddress": "21 2nd Street", | ||
2186 | 13 | "city": "New York", | ||
2187 | 14 | "state": "NY", | ||
2188 | 15 | "postalCode": 10021 | ||
2189 | 16 | }, | ||
2190 | 17 | "phoneNumbers": [ | ||
2191 | 18 | "212 732-1234", | ||
2192 | 19 | "646 123-4567" | ||
2193 | 20 | ] | ||
2194 | 21 | }, | ||
2195 | 22 | { | ||
2196 | 23 | "firstName": "John", | ||
2197 | 24 | "lastName": "Smith", | ||
2198 | 25 | "address": { | ||
2199 | 26 | "streetAddress": "21 2nd Street", | ||
2200 | 27 | "city": "New York", | ||
2201 | 28 | "state": "NY", | ||
2202 | 29 | "postalCode": 10021 | ||
2203 | 30 | }, | ||
2204 | 31 | "phoneNumbers": [ | ||
2205 | 32 | "212 732-1234", | ||
2206 | 33 | "646 123-4567" | ||
2207 | 34 | ] | ||
2208 | 35 | }]'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2209 | 36 | <json-param name="mapping" value="simple-json" /> | ||
2210 | 37 | </options>) | ||
2211 | 38 | 0 | ||
2212 | === removed file 'test_json/Queries/converters/jansson/parse_json_03.xq' | |||
2213 | --- test_json/Queries/converters/jansson/parse_json_03.xq 2011-08-07 21:55:48 +0000 | |||
2214 | +++ test_json/Queries/converters/jansson/parse_json_03.xq 1970-01-01 00:00:00 +0000 | |||
2215 | @@ -1,8 +0,0 @@ | |||
2216 | 1 | (: try parsing a Unicode UTF-8 value :) | ||
2217 | 2 | |||
2218 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2219 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2220 | 5 | |||
2221 | 6 | json:parse(('{"mdash": "–"}'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2222 | 7 | <json-param name="mapping" value="simple-json" /> | ||
2223 | 8 | </options>) | ||
2224 | 9 | \ No newline at end of file | 0 | \ No newline at end of file |
2225 | 10 | 1 | ||
2226 | === removed file 'test_json/Queries/converters/jansson/parse_json_04.spec' | |||
2227 | --- test_json/Queries/converters/jansson/parse_json_04.spec 2011-08-18 22:09:48 +0000 | |||
2228 | +++ test_json/Queries/converters/jansson/parse_json_04.spec 1970-01-01 00:00:00 +0000 | |||
2229 | @@ -1,1 +0,0 @@ | |||
2230 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:ParseError | ||
2231 | 2 | 0 | ||
2232 | === removed file 'test_json/Queries/converters/jansson/parse_json_04.xq' | |||
2233 | --- test_json/Queries/converters/jansson/parse_json_04.xq 2011-08-07 21:55:48 +0000 | |||
2234 | +++ test_json/Queries/converters/jansson/parse_json_04.xq 1970-01-01 00:00:00 +0000 | |||
2235 | @@ -1,8 +0,0 @@ | |||
2236 | 1 | (: try parsing an empty value :) | ||
2237 | 2 | |||
2238 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2239 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2240 | 5 | |||
2241 | 6 | json:parse((<a/>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2242 | 7 | <json-param name="mapping" value="simple-json" /> | ||
2243 | 8 | </options>) | ||
2244 | 9 | \ No newline at end of file | 0 | \ No newline at end of file |
2245 | 10 | 1 | ||
2246 | === removed file 'test_json/Queries/converters/jansson/parse_json_05.spec' | |||
2247 | --- test_json/Queries/converters/jansson/parse_json_05.spec 2011-08-18 22:09:48 +0000 | |||
2248 | +++ test_json/Queries/converters/jansson/parse_json_05.spec 1970-01-01 00:00:00 +0000 | |||
2249 | @@ -1,1 +0,0 @@ | |||
2250 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:ParseError | ||
2251 | 2 | 0 | ||
2252 | === removed file 'test_json/Queries/converters/jansson/parse_json_05.xq' | |||
2253 | --- test_json/Queries/converters/jansson/parse_json_05.xq 2011-08-07 21:55:48 +0000 | |||
2254 | +++ test_json/Queries/converters/jansson/parse_json_05.xq 1970-01-01 00:00:00 +0000 | |||
2255 | @@ -1,14 +0,0 @@ | |||
2256 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2257 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2258 | 3 | |||
2259 | 4 | json:parse(('[ "ul", | ||
2260 | 5 | [ "li", | ||
2261 | 6 | true], | ||
2262 | 7 | [ "li", | ||
2263 | 8 | {"href":"driving.html", "title":"Driving"}, | ||
2264 | 9 | "Second item"], | ||
2265 | 10 | [ "li", null], | ||
2266 | 11 | [ "li", -14e12] | ||
2267 | 12 | '),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2268 | 13 | <json-param name="mapping" value="simple-json" /> | ||
2269 | 14 | </options>) | ||
2270 | 15 | 0 | ||
2271 | === removed file 'test_json/Queries/converters/jansson/parse_json_06.xq' | |||
2272 | --- test_json/Queries/converters/jansson/parse_json_06.xq 2011-08-07 21:55:48 +0000 | |||
2273 | +++ test_json/Queries/converters/jansson/parse_json_06.xq 1970-01-01 00:00:00 +0000 | |||
2274 | @@ -1,8 +0,0 @@ | |||
2275 | 1 | (: json:parse with uncommon characters :) | ||
2276 | 2 | |||
2277 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2278 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2279 | 5 | |||
2280 | 6 | json:parse('{ "web-app": "!_\"-\\?*.$+" }',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2281 | 7 | <json-param name="mapping" value="simple-json" /> | ||
2282 | 8 | </options>) | ||
2283 | 9 | 0 | ||
2284 | === removed file 'test_json/Queries/converters/jansson/parse_json_07.spec' | |||
2285 | --- test_json/Queries/converters/jansson/parse_json_07.spec 2011-05-31 15:21:09 +0000 | |||
2286 | +++ test_json/Queries/converters/jansson/parse_json_07.spec 1970-01-01 00:00:00 +0000 | |||
2287 | @@ -1,1 +0,0 @@ | |||
2288 | 1 | Comparison: Ignore | ||
2289 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2290 | 3 | 1 | ||
2291 | === removed file 'test_json/Queries/converters/jansson/parse_json_07.xq' | |||
2292 | --- test_json/Queries/converters/jansson/parse_json_07.xq 2011-08-07 21:55:48 +0000 | |||
2293 | +++ test_json/Queries/converters/jansson/parse_json_07.xq 1970-01-01 00:00:00 +0000 | |||
2294 | @@ -1,13 +0,0 @@ | |||
2295 | 1 | (: json:parse testing numbers and decimals :) | ||
2296 | 2 | |||
2297 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2298 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2299 | 5 | |||
2300 | 6 | json:parse('{ "special-numbers": { | ||
2301 | 7 | "decimal": 2.89, | ||
2302 | 8 | "e": 2E+6, | ||
2303 | 9 | "negative": -1.89 | ||
2304 | 10 | } | ||
2305 | 11 | }',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2306 | 12 | <json-param name="mapping" value="simple-json" /> | ||
2307 | 13 | </options>) | ||
2308 | 14 | 0 | ||
2309 | === removed file 'test_json/Queries/converters/jansson/parse_json_08.xq' | |||
2310 | --- test_json/Queries/converters/jansson/parse_json_08.xq 2011-08-07 21:55:48 +0000 | |||
2311 | +++ test_json/Queries/converters/jansson/parse_json_08.xq 1970-01-01 00:00:00 +0000 | |||
2312 | @@ -1,8 +0,0 @@ | |||
2313 | 1 | (: json:parse testing null handling :) | ||
2314 | 2 | |||
2315 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2316 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2317 | 5 | |||
2318 | 6 | json:parse('{ "web-app": null }',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2319 | 7 | <json-param name="mapping" value="simple-json" /> | ||
2320 | 8 | </options>) | ||
2321 | 9 | 0 | ||
2322 | === removed file 'test_json/Queries/converters/jansson/parse_json_09.spec' | |||
2323 | --- test_json/Queries/converters/jansson/parse_json_09.spec 2011-05-31 15:21:09 +0000 | |||
2324 | +++ test_json/Queries/converters/jansson/parse_json_09.spec 1970-01-01 00:00:00 +0000 | |||
2325 | @@ -1,1 +0,0 @@ | |||
2326 | 1 | Comparison: Ignore | ||
2327 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2328 | 3 | 1 | ||
2329 | === removed file 'test_json/Queries/converters/jansson/parse_json_09.xq' | |||
2330 | --- test_json/Queries/converters/jansson/parse_json_09.xq 2011-08-07 21:55:48 +0000 | |||
2331 | +++ test_json/Queries/converters/jansson/parse_json_09.xq 1970-01-01 00:00:00 +0000 | |||
2332 | @@ -1,26 +0,0 @@ | |||
2333 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2334 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2335 | 3 | |||
2336 | 4 | json:parse('{ | ||
2337 | 5 | "firstName": "John", | ||
2338 | 6 | "state": null, | ||
2339 | 7 | "bool": true , | ||
2340 | 8 | "numbers": [1,2,3] , | ||
2341 | 9 | "address": { | ||
2342 | 10 | "streetAddress": "21 2nd Street", | ||
2343 | 11 | "state": null, | ||
2344 | 12 | "postalCode": 10021 , | ||
2345 | 13 | "literals": [true,false,null], | ||
2346 | 14 | "delivery": { | ||
2347 | 15 | "streetAddress": "StreetName", | ||
2348 | 16 | "city": "CityName", | ||
2349 | 17 | "state": "StateName" | ||
2350 | 18 | }} , | ||
2351 | 19 | "strings": [ | ||
2352 | 20 | "one", | ||
2353 | 21 | "two", | ||
2354 | 22 | "three", | ||
2355 | 23 | "four" ] | ||
2356 | 24 | }',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2357 | 25 | <json-param name="mapping" value="simple-json" /> | ||
2358 | 26 | </options>) | ||
2359 | 27 | 0 | ||
2360 | === removed file 'test_json/Queries/converters/jansson/parse_json_10.spec' | |||
2361 | --- test_json/Queries/converters/jansson/parse_json_10.spec 2011-05-31 15:21:09 +0000 | |||
2362 | +++ test_json/Queries/converters/jansson/parse_json_10.spec 1970-01-01 00:00:00 +0000 | |||
2363 | @@ -1,1 +0,0 @@ | |||
2364 | 1 | Comparison: Ignore | ||
2365 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2366 | 3 | 1 | ||
2367 | === removed file 'test_json/Queries/converters/jansson/parse_json_10.xq' | |||
2368 | --- test_json/Queries/converters/jansson/parse_json_10.xq 2011-08-07 21:55:48 +0000 | |||
2369 | +++ test_json/Queries/converters/jansson/parse_json_10.xq 1970-01-01 00:00:00 +0000 | |||
2370 | @@ -1,40 +0,0 @@ | |||
2371 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2372 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2373 | 3 | |||
2374 | 4 | json:parse('[{ | ||
2375 | 5 | "firstName": "John", | ||
2376 | 6 | "lastName": "Smith", | ||
2377 | 7 | "address": { | ||
2378 | 8 | "streetAddress": "21 2nd Street", | ||
2379 | 9 | "city": "New York", | ||
2380 | 10 | "state": "NY", | ||
2381 | 11 | "postalCode": 10021 | ||
2382 | 12 | }, | ||
2383 | 13 | "phoneNumbers": [ | ||
2384 | 14 | "212 732-1234", | ||
2385 | 15 | "646 123-4567" | ||
2386 | 16 | ] | ||
2387 | 17 | }, | ||
2388 | 18 | { | ||
2389 | 19 | "firstName": "John", | ||
2390 | 20 | "state": null, | ||
2391 | 21 | "bool": true , | ||
2392 | 22 | "numbers": [1,2,3] , | ||
2393 | 23 | "address": { | ||
2394 | 24 | "streetAddress": "21 2nd Street", | ||
2395 | 25 | "state": null, | ||
2396 | 26 | "postalCode": 10021 , | ||
2397 | 27 | "literals": [true,false,null], | ||
2398 | 28 | "delivery": { | ||
2399 | 29 | "streetAddress": "StreetName", | ||
2400 | 30 | "city": "CityName", | ||
2401 | 31 | "state": "StateName" | ||
2402 | 32 | }} , | ||
2403 | 33 | "strings": [ | ||
2404 | 34 | "one", | ||
2405 | 35 | "two", | ||
2406 | 36 | "three", | ||
2407 | 37 | "four" ] | ||
2408 | 38 | }]',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2409 | 39 | <json-param name="mapping" value="simple-json" /> | ||
2410 | 40 | </options>) | ||
2411 | 41 | 0 | ||
2412 | === removed file 'test_json/Queries/converters/jansson/parse_json_11.spec' | |||
2413 | --- test_json/Queries/converters/jansson/parse_json_11.spec 2011-05-31 15:21:09 +0000 | |||
2414 | +++ test_json/Queries/converters/jansson/parse_json_11.spec 1970-01-01 00:00:00 +0000 | |||
2415 | @@ -1,1 +0,0 @@ | |||
2416 | 1 | Comparison: Ignore | ||
2417 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2418 | 3 | 1 | ||
2419 | === removed file 'test_json/Queries/converters/jansson/parse_json_11.xq' | |||
2420 | --- test_json/Queries/converters/jansson/parse_json_11.xq 2011-10-06 07:40:17 +0000 | |||
2421 | +++ test_json/Queries/converters/jansson/parse_json_11.xq 1970-01-01 00:00:00 +0000 | |||
2422 | @@ -1,20 +0,0 @@ | |||
2423 | 1 | (: the comparison method for this test is set to Ignore because the order in which the children | ||
2424 | 2 | are returned in jansson 1.2, 1.3, 2.0 is different:) | ||
2425 | 3 | |||
2426 | 4 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2427 | 5 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2428 | 6 | |||
2429 | 7 | json:parse(('{ | ||
2430 | 8 | "firstName": "John", | ||
2431 | 9 | "lastName": "Smith", | ||
2432 | 10 | "address": { | ||
2433 | 11 | "streetAddress": "21 2nd Street", | ||
2434 | 12 | "city": "New York", | ||
2435 | 13 | "state": "NY", | ||
2436 | 14 | "postalCode": 10021 | ||
2437 | 15 | }, | ||
2438 | 16 | "phoneNumbers": [ | ||
2439 | 17 | "212 732-1234", | ||
2440 | 18 | "646 123-4567" | ||
2441 | 19 | ] | ||
2442 | 20 | }')) | ||
2443 | 21 | 0 | ||
2444 | === removed file 'test_json/Queries/converters/jansson/parse_json_12.xq' | |||
2445 | --- test_json/Queries/converters/jansson/parse_json_12.xq 2011-12-06 14:20:24 +0000 | |||
2446 | +++ test_json/Queries/converters/jansson/parse_json_12.xq 1970-01-01 00:00:00 +0000 | |||
2447 | @@ -1,4 +0,0 @@ | |||
2448 | 1 | import module namespace json="http://www.zorba-xquery.com/modules/converters/json"; | ||
2449 | 2 | declare variable $json-value := '{"html":"<b>bold</b>"}'; | ||
2450 | 3 | |||
2451 | 4 | json:serialize(json:parse($json-value)) | ||
2452 | 5 | 0 | ||
2453 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_01.xq' | |||
2454 | --- test_json/Queries/converters/jansson/parse_json_ml_01.xq 2011-08-11 20:09:07 +0000 | |||
2455 | +++ test_json/Queries/converters/jansson/parse_json_ml_01.xq 1970-01-01 00:00:00 +0000 | |||
2456 | @@ -1,27 +0,0 @@ | |||
2457 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2458 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2459 | 3 | |||
2460 | 4 | json:parse((' | ||
2461 | 5 | ["ul", | ||
2462 | 6 | ["li", | ||
2463 | 7 | { "style" : "color:red" }, | ||
2464 | 8 | "First Item" | ||
2465 | 9 | ], | ||
2466 | 10 | ["li", | ||
2467 | 11 | { | ||
2468 | 12 | "title" : "Some hover text.", | ||
2469 | 13 | "style" : "color:green" | ||
2470 | 14 | }, | ||
2471 | 15 | "Second Item" | ||
2472 | 16 | ], | ||
2473 | 17 | ["li", | ||
2474 | 18 | ["span", | ||
2475 | 19 | { "class" : "code-example-third" }, | ||
2476 | 20 | "Third" | ||
2477 | 21 | ], | ||
2478 | 22 | " Item" | ||
2479 | 23 | ] | ||
2480 | 24 | ]'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" | ||
2481 | 25 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
2482 | 26 | <json-param name="mapping" value="json-ml" type="array"/> | ||
2483 | 27 | </options>) | ||
2484 | 28 | \ No newline at end of file | 0 | \ No newline at end of file |
2485 | 29 | 1 | ||
2486 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_02.xq' | |||
2487 | --- test_json/Queries/converters/jansson/parse_json_ml_02.xq 2011-08-11 20:09:07 +0000 | |||
2488 | +++ test_json/Queries/converters/jansson/parse_json_ml_02.xq 1970-01-01 00:00:00 +0000 | |||
2489 | @@ -1,65 +0,0 @@ | |||
2490 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2491 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2492 | 3 | |||
2493 | 4 | json:parse((' | ||
2494 | 5 | ["table", | ||
2495 | 6 | { | ||
2496 | 7 | "class" : "MyTable", | ||
2497 | 8 | "style" : "background-color:yellow" | ||
2498 | 9 | }, | ||
2499 | 10 | ["tr", | ||
2500 | 11 | ["td", | ||
2501 | 12 | { | ||
2502 | 13 | "class" : "MyTD", | ||
2503 | 14 | "style" : "border:1px solid black" | ||
2504 | 15 | }, | ||
2505 | 16 | "#550758" | ||
2506 | 17 | ], | ||
2507 | 18 | ["td", | ||
2508 | 19 | { | ||
2509 | 20 | "class" : "MyTD", | ||
2510 | 21 | "style" : "background-color:red" | ||
2511 | 22 | }, | ||
2512 | 23 | "Example text here" | ||
2513 | 24 | ] | ||
2514 | 25 | ], | ||
2515 | 26 | ["tr", | ||
2516 | 27 | ["td", | ||
2517 | 28 | { | ||
2518 | 29 | "class" : "MyTD", | ||
2519 | 30 | "style" : "border:1px solid black" | ||
2520 | 31 | }, | ||
2521 | 32 | "#993101" | ||
2522 | 33 | ], | ||
2523 | 34 | ["td", | ||
2524 | 35 | { | ||
2525 | 36 | "class" : "MyTD", | ||
2526 | 37 | "style" : "background-color:green" | ||
2527 | 38 | }, | ||
2528 | 39 | "127624015" | ||
2529 | 40 | ] | ||
2530 | 41 | ], | ||
2531 | 42 | ["tr", | ||
2532 | 43 | ["td", | ||
2533 | 44 | { | ||
2534 | 45 | "class" : "MyTD", | ||
2535 | 46 | "style" : "border:1px solid black" | ||
2536 | 47 | }, | ||
2537 | 48 | "#E33D87" | ||
2538 | 49 | ], | ||
2539 | 50 | ["td", | ||
2540 | 51 | { | ||
2541 | 52 | "class" : "MyTD", | ||
2542 | 53 | "style" : "background-color:blue" | ||
2543 | 54 | }, | ||
2544 | 55 | "\u00A0", | ||
2545 | 56 | ["span", | ||
2546 | 57 | { "style" : "background-color:maroon" }, | ||
2547 | 58 | "\u00A9" | ||
2548 | 59 | ], | ||
2549 | 60 | "\u00A0" | ||
2550 | 61 | ] | ||
2551 | 62 | ] | ||
2552 | 63 | ]'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2553 | 64 | <json-param name="mapping" value="json-ml" type="array"/> | ||
2554 | 65 | </options>) | ||
2555 | 66 | 0 | ||
2556 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_03.spec' | |||
2557 | --- test_json/Queries/converters/jansson/parse_json_ml_03.spec 2011-08-18 22:09:48 +0000 | |||
2558 | +++ test_json/Queries/converters/jansson/parse_json_ml_03.spec 1970-01-01 00:00:00 +0000 | |||
2559 | @@ -1,1 +0,0 @@ | |||
2560 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:ParseError | ||
2561 | 2 | 0 | ||
2562 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_03.xq' | |||
2563 | --- test_json/Queries/converters/jansson/parse_json_ml_03.xq 2011-08-11 20:09:07 +0000 | |||
2564 | +++ test_json/Queries/converters/jansson/parse_json_ml_03.xq 1970-01-01 00:00:00 +0000 | |||
2565 | @@ -1,8 +0,0 @@ | |||
2566 | 1 | (: jsonml:parse with empty parameter :) | ||
2567 | 2 | |||
2568 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2569 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2570 | 5 | |||
2571 | 6 | json:parse(<a/>,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2572 | 7 | <json-param name="mapping" value="json-ml" type="array"/> | ||
2573 | 8 | </options>) | ||
2574 | 9 | 0 | ||
2575 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_04.spec' | |||
2576 | --- test_json/Queries/converters/jansson/parse_json_ml_04.spec 2011-08-18 22:09:48 +0000 | |||
2577 | +++ test_json/Queries/converters/jansson/parse_json_ml_04.spec 1970-01-01 00:00:00 +0000 | |||
2578 | @@ -1,1 +0,0 @@ | |||
2579 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:ParseError | ||
2580 | 2 | 0 | ||
2581 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_04.xq' | |||
2582 | --- test_json/Queries/converters/jansson/parse_json_ml_04.xq 2011-08-11 20:09:07 +0000 | |||
2583 | +++ test_json/Queries/converters/jansson/parse_json_ml_04.xq 1970-01-01 00:00:00 +0000 | |||
2584 | @@ -1,16 +0,0 @@ | |||
2585 | 1 | (: jsonml:parse with invalid parameter :) | ||
2586 | 2 | |||
2587 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2588 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2589 | 5 | |||
2590 | 6 | json:parse(('{ | ||
2591 | 7 | "firstName": "John", | ||
2592 | 8 | "lastName": "Smith", | ||
2593 | 9 | "address": { | ||
2594 | 10 | "streetAddress": "21 2nd Street", | ||
2595 | 11 | "city": "New York", | ||
2596 | 12 | "state": "NY", | ||
2597 | 13 | "postalCode": 10021 | ||
2598 | 14 | }'),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2599 | 15 | <json-param name="mapping" value="json-ml" type="array"/> | ||
2600 | 16 | </options>) | ||
2601 | 17 | 0 | ||
2602 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_05.xq' | |||
2603 | --- test_json/Queries/converters/jansson/parse_json_ml_05.xq 2011-10-06 07:40:17 +0000 | |||
2604 | +++ test_json/Queries/converters/jansson/parse_json_ml_05.xq 1970-01-01 00:00:00 +0000 | |||
2605 | @@ -1,24 +0,0 @@ | |||
2606 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2607 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2608 | 3 | |||
2609 | 4 | json:parse-ml((' | ||
2610 | 5 | ["ul", | ||
2611 | 6 | ["li", | ||
2612 | 7 | { "style" : "color:red" }, | ||
2613 | 8 | "First Item" | ||
2614 | 9 | ], | ||
2615 | 10 | ["li", | ||
2616 | 11 | { | ||
2617 | 12 | "title" : "Some hover text.", | ||
2618 | 13 | "style" : "color:green" | ||
2619 | 14 | }, | ||
2620 | 15 | "Second Item" | ||
2621 | 16 | ], | ||
2622 | 17 | ["li", | ||
2623 | 18 | ["span", | ||
2624 | 19 | { "class" : "code-example-third" }, | ||
2625 | 20 | "Third" | ||
2626 | 21 | ], | ||
2627 | 22 | " Item" | ||
2628 | 23 | ] | ||
2629 | 24 | ]')) | ||
2630 | 25 | \ No newline at end of file | 0 | \ No newline at end of file |
2631 | 26 | 1 | ||
2632 | === removed file 'test_json/Queries/converters/jansson/parse_json_ml_06.xq' | |||
2633 | --- test_json/Queries/converters/jansson/parse_json_ml_06.xq 2011-12-06 14:20:24 +0000 | |||
2634 | +++ test_json/Queries/converters/jansson/parse_json_ml_06.xq 1970-01-01 00:00:00 +0000 | |||
2635 | @@ -1,7 +0,0 @@ | |||
2636 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2637 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2638 | 3 | |||
2639 | 4 | json:parse('["html" ,"<b>bold</b>"]',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" | ||
2640 | 5 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
2641 | 6 | <json-param name="mapping" value="json-ml" type="array"/> | ||
2642 | 7 | </options>) | ||
2643 | 8 | 0 | ||
2644 | === removed file 'test_json/Queries/converters/jansson/serialize_json_01.xq' | |||
2645 | --- test_json/Queries/converters/jansson/serialize_json_01.xq 2011-08-11 20:09:07 +0000 | |||
2646 | +++ test_json/Queries/converters/jansson/serialize_json_01.xq 1970-01-01 00:00:00 +0000 | |||
2647 | @@ -1,9 +0,0 @@ | |||
2648 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2649 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2650 | 3 | |||
2651 | 4 | |||
2652 | 5 | declare 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>; | ||
2653 | 6 | |||
2654 | 7 | json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2655 | 8 | <json-param name="mapping" value="simple-json" type="array"/> | ||
2656 | 9 | </options>) | ||
2657 | 10 | \ No newline at end of file | 0 | \ No newline at end of file |
2658 | 11 | 1 | ||
2659 | === removed file 'test_json/Queries/converters/jansson/serialize_json_02.xq' | |||
2660 | --- test_json/Queries/converters/jansson/serialize_json_02.xq 2011-08-11 20:09:07 +0000 | |||
2661 | +++ test_json/Queries/converters/jansson/serialize_json_02.xq 1970-01-01 00:00:00 +0000 | |||
2662 | @@ -1,8 +0,0 @@ | |||
2663 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2664 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2665 | 3 | |||
2666 | 4 | declare 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>; | ||
2667 | 5 | |||
2668 | 6 | json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2669 | 7 | <json-param name="mapping" value="simple-json" type="array"/> | ||
2670 | 8 | </options>) | ||
2671 | 9 | \ No newline at end of file | 0 | \ No newline at end of file |
2672 | 10 | 1 | ||
2673 | === removed file 'test_json/Queries/converters/jansson/serialize_json_03.spec' | |||
2674 | --- test_json/Queries/converters/jansson/serialize_json_03.spec 2011-08-18 22:09:48 +0000 | |||
2675 | +++ test_json/Queries/converters/jansson/serialize_json_03.spec 1970-01-01 00:00:00 +0000 | |||
2676 | @@ -1,1 +0,0 @@ | |||
2677 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM | ||
2678 | 2 | 0 | ||
2679 | === removed file 'test_json/Queries/converters/jansson/serialize_json_03.xq' | |||
2680 | --- test_json/Queries/converters/jansson/serialize_json_03.xq 2011-08-11 20:09:07 +0000 | |||
2681 | +++ test_json/Queries/converters/jansson/serialize_json_03.xq 1970-01-01 00:00:00 +0000 | |||
2682 | @@ -1,8 +0,0 @@ | |||
2683 | 1 | (: json:serialize called with wrong parameter: comment node:) | ||
2684 | 2 | |||
2685 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2686 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2687 | 5 | |||
2688 | 6 | json:serialize((<!--comment-->),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2689 | 7 | <json-param name="mapping" value="simple-json" type="array"/> | ||
2690 | 8 | </options>) | ||
2691 | 9 | 0 | ||
2692 | === removed file 'test_json/Queries/converters/jansson/serialize_json_04.xq' | |||
2693 | --- test_json/Queries/converters/jansson/serialize_json_04.xq 2011-08-07 21:55:48 +0000 | |||
2694 | +++ test_json/Queries/converters/jansson/serialize_json_04.xq 1970-01-01 00:00:00 +0000 | |||
2695 | @@ -1,10 +0,0 @@ | |||
2696 | 1 | (: json:serialize test escaping of double quotes :) | ||
2697 | 2 | |||
2698 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2699 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2700 | 5 | |||
2701 | 6 | json:serialize((<json type="object"> | ||
2702 | 7 | <pair name="firstName" type="string">\"</pair> | ||
2703 | 8 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2704 | 9 | <json-param name="mapping" value="simple-json" /> | ||
2705 | 10 | </options>) | ||
2706 | 11 | 0 | ||
2707 | === removed file 'test_json/Queries/converters/jansson/serialize_json_05.xq' | |||
2708 | --- test_json/Queries/converters/jansson/serialize_json_05.xq 2011-08-07 21:55:48 +0000 | |||
2709 | +++ test_json/Queries/converters/jansson/serialize_json_05.xq 1970-01-01 00:00:00 +0000 | |||
2710 | @@ -1,10 +0,0 @@ | |||
2711 | 1 | (: json:serialize some pitfall characters :) | ||
2712 | 2 | |||
2713 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2714 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2715 | 5 | |||
2716 | 6 | json:serialize((<json type="object"> | ||
2717 | 7 | <pair name="name" type="string">\"\\\/\b\f\n\r\t</pair> | ||
2718 | 8 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2719 | 9 | <json-param name="mapping" value="simple-json" /> | ||
2720 | 10 | </options>) | ||
2721 | 11 | 0 | ||
2722 | === removed file 'test_json/Queries/converters/jansson/serialize_json_06.spec' | |||
2723 | --- test_json/Queries/converters/jansson/serialize_json_06.spec 2011-08-18 22:09:48 +0000 | |||
2724 | +++ test_json/Queries/converters/jansson/serialize_json_06.spec 1970-01-01 00:00:00 +0000 | |||
2725 | @@ -1,1 +0,0 @@ | |||
2726 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM | ||
2727 | 2 | 0 | ||
2728 | === removed file 'test_json/Queries/converters/jansson/serialize_json_06.xq' | |||
2729 | --- test_json/Queries/converters/jansson/serialize_json_06.xq 2011-08-07 21:55:48 +0000 | |||
2730 | +++ test_json/Queries/converters/jansson/serialize_json_06.xq 1970-01-01 00:00:00 +0000 | |||
2731 | @@ -1,10 +0,0 @@ | |||
2732 | 1 | (: type value missing :) | ||
2733 | 2 | |||
2734 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2735 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2736 | 5 | |||
2737 | 6 | json:serialize((<json type="object"> | ||
2738 | 7 | <pair name="name" type="">value</pair> | ||
2739 | 8 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2740 | 9 | <json-param name="mapping" value="simple-json" /> | ||
2741 | 10 | </options>) | ||
2742 | 11 | 0 | ||
2743 | === removed file 'test_json/Queries/converters/jansson/serialize_json_07.spec' | |||
2744 | --- test_json/Queries/converters/jansson/serialize_json_07.spec 2011-08-18 22:09:48 +0000 | |||
2745 | +++ test_json/Queries/converters/jansson/serialize_json_07.spec 1970-01-01 00:00:00 +0000 | |||
2746 | @@ -1,1 +0,0 @@ | |||
2747 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM | ||
2748 | 2 | 0 | ||
2749 | === removed file 'test_json/Queries/converters/jansson/serialize_json_07.xq' | |||
2750 | --- test_json/Queries/converters/jansson/serialize_json_07.xq 2011-08-07 21:55:48 +0000 | |||
2751 | +++ test_json/Queries/converters/jansson/serialize_json_07.xq 1970-01-01 00:00:00 +0000 | |||
2752 | @@ -1,10 +0,0 @@ | |||
2753 | 1 | (: type value wrong :) | ||
2754 | 2 | |||
2755 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2756 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2757 | 5 | |||
2758 | 6 | json:serialize((<json type="object"> | ||
2759 | 7 | <pair name="name" type="huhu">value</pair> | ||
2760 | 8 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2761 | 9 | <json-param name="mapping" value="simple-json" /> | ||
2762 | 10 | </options>) | ||
2763 | 11 | 0 | ||
2764 | === removed file 'test_json/Queries/converters/jansson/serialize_json_08.spec' | |||
2765 | --- test_json/Queries/converters/jansson/serialize_json_08.spec 2011-08-18 22:09:48 +0000 | |||
2766 | +++ test_json/Queries/converters/jansson/serialize_json_08.spec 1970-01-01 00:00:00 +0000 | |||
2767 | @@ -1,1 +0,0 @@ | |||
2768 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM | ||
2769 | 2 | 0 | ||
2770 | === removed file 'test_json/Queries/converters/jansson/serialize_json_08.xq' | |||
2771 | --- test_json/Queries/converters/jansson/serialize_json_08.xq 2011-08-07 21:55:48 +0000 | |||
2772 | +++ test_json/Queries/converters/jansson/serialize_json_08.xq 1970-01-01 00:00:00 +0000 | |||
2773 | @@ -1,12 +0,0 @@ | |||
2774 | 1 | (: wrong value for array :) | ||
2775 | 2 | |||
2776 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2777 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2778 | 5 | |||
2779 | 6 | json:serialize((<json type="object"> | ||
2780 | 7 | <pair name="name" type="array"> | ||
2781 | 8 | <pair name="wrong" type="string">value</pair> | ||
2782 | 9 | </pair> | ||
2783 | 10 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2784 | 11 | <json-param name="mapping" value="simple-json" /> | ||
2785 | 12 | </options>) | ||
2786 | 13 | 0 | ||
2787 | === removed file 'test_json/Queries/converters/jansson/serialize_json_09.xq' | |||
2788 | --- test_json/Queries/converters/jansson/serialize_json_09.xq 2011-08-07 21:55:48 +0000 | |||
2789 | +++ test_json/Queries/converters/jansson/serialize_json_09.xq 1970-01-01 00:00:00 +0000 | |||
2790 | @@ -1,15 +0,0 @@ | |||
2791 | 1 | (: valid json generation: array in an array :) | ||
2792 | 2 | |||
2793 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2794 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2795 | 5 | |||
2796 | 6 | json:serialize((<json type="object"> | ||
2797 | 7 | <pair name="servlet" type="array"> | ||
2798 | 8 | <item type="array"> | ||
2799 | 9 | <item type="string">value1</item> | ||
2800 | 10 | </item> | ||
2801 | 11 | <item type="string">value2</item> | ||
2802 | 12 | </pair> | ||
2803 | 13 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2804 | 14 | <json-param name="mapping" value="simple-json" /> | ||
2805 | 15 | </options>) | ||
2806 | 16 | 0 | ||
2807 | === removed file 'test_json/Queries/converters/jansson/serialize_json_10.spec' | |||
2808 | --- test_json/Queries/converters/jansson/serialize_json_10.spec 2011-05-31 15:21:09 +0000 | |||
2809 | +++ test_json/Queries/converters/jansson/serialize_json_10.spec 1970-01-01 00:00:00 +0000 | |||
2810 | @@ -1,1 +0,0 @@ | |||
2811 | 1 | Comparison: Ignore | ||
2812 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2813 | 3 | 1 | ||
2814 | === removed file 'test_json/Queries/converters/jansson/serialize_json_10.xq' | |||
2815 | --- test_json/Queries/converters/jansson/serialize_json_10.xq 2011-08-07 21:55:48 +0000 | |||
2816 | +++ test_json/Queries/converters/jansson/serialize_json_10.xq 1970-01-01 00:00:00 +0000 | |||
2817 | @@ -1,15 +0,0 @@ | |||
2818 | 1 | (: object contained in an array is allowed :) | ||
2819 | 2 | |||
2820 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2821 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2822 | 5 | |||
2823 | 6 | json:serialize((<json type="object"> | ||
2824 | 7 | <pair name="servlet" type="array"> | ||
2825 | 8 | <item type="object"> | ||
2826 | 9 | <pair name="name" type="string">value1</pair> | ||
2827 | 10 | </item> | ||
2828 | 11 | <item type="string">value2</item> | ||
2829 | 12 | </pair> | ||
2830 | 13 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2831 | 14 | <json-param name="mapping" value="simple-json" /> | ||
2832 | 15 | </options>) | ||
2833 | 16 | 0 | ||
2834 | === removed file 'test_json/Queries/converters/jansson/serialize_json_11.spec' | |||
2835 | --- test_json/Queries/converters/jansson/serialize_json_11.spec 2011-08-18 22:09:48 +0000 | |||
2836 | +++ test_json/Queries/converters/jansson/serialize_json_11.spec 1970-01-01 00:00:00 +0000 | |||
2837 | @@ -1,1 +0,0 @@ | |||
2838 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM | ||
2839 | 2 | 0 | ||
2840 | === removed file 'test_json/Queries/converters/jansson/serialize_json_11.xq' | |||
2841 | --- test_json/Queries/converters/jansson/serialize_json_11.xq 2011-08-07 21:55:48 +0000 | |||
2842 | +++ test_json/Queries/converters/jansson/serialize_json_11.xq 1970-01-01 00:00:00 +0000 | |||
2843 | @@ -1,10 +0,0 @@ | |||
2844 | 1 | (: type attribute missing :) | ||
2845 | 2 | |||
2846 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2847 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2848 | 5 | |||
2849 | 6 | json:serialize((<json type="object"> | ||
2850 | 7 | <pair name="name">value</pair> | ||
2851 | 8 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2852 | 9 | <json-param name="mapping" value="simple-json" /> | ||
2853 | 10 | </options>) | ||
2854 | 11 | 0 | ||
2855 | === removed file 'test_json/Queries/converters/jansson/serialize_json_12.spec' | |||
2856 | --- test_json/Queries/converters/jansson/serialize_json_12.spec 2011-08-18 22:09:48 +0000 | |||
2857 | +++ test_json/Queries/converters/jansson/serialize_json_12.spec 1970-01-01 00:00:00 +0000 | |||
2858 | @@ -1,1 +0,0 @@ | |||
2859 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM | ||
2860 | 2 | 0 | ||
2861 | === removed file 'test_json/Queries/converters/jansson/serialize_json_12.xq' | |||
2862 | --- test_json/Queries/converters/jansson/serialize_json_12.xq 2011-08-07 21:55:48 +0000 | |||
2863 | +++ test_json/Queries/converters/jansson/serialize_json_12.xq 1970-01-01 00:00:00 +0000 | |||
2864 | @@ -1,10 +0,0 @@ | |||
2865 | 1 | (: name attribute missing :) | ||
2866 | 2 | |||
2867 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2868 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2869 | 5 | |||
2870 | 6 | json:serialize((<json type="object"> | ||
2871 | 7 | <pair type="string">value</pair> | ||
2872 | 8 | </json>),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2873 | 9 | <json-param name="mapping" value="simple-json" /> | ||
2874 | 10 | </options>) | ||
2875 | 11 | 0 | ||
2876 | === removed file 'test_json/Queries/converters/jansson/serialize_json_13.xq' | |||
2877 | --- test_json/Queries/converters/jansson/serialize_json_13.xq 2011-08-07 21:55:48 +0000 | |||
2878 | +++ test_json/Queries/converters/jansson/serialize_json_13.xq 1970-01-01 00:00:00 +0000 | |||
2879 | @@ -1,16 +0,0 @@ | |||
2880 | 1 | (: valid json generation: comments should be ignored :) | ||
2881 | 2 | |||
2882 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2883 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2884 | 5 | |||
2885 | 6 | declare variable $local:json := | ||
2886 | 7 | <json type="object"> | ||
2887 | 8 | <pair name="servlet" type="array"> | ||
2888 | 9 | <!--comment--> | ||
2889 | 10 | <item type="string">value</item> | ||
2890 | 11 | </pair> | ||
2891 | 12 | </json>; | ||
2892 | 13 | |||
2893 | 14 | json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2894 | 15 | <json-param name="mapping" value="simple-json" /> | ||
2895 | 16 | </options>) | ||
2896 | 17 | 0 | ||
2897 | === removed file 'test_json/Queries/converters/jansson/serialize_json_14.xq' | |||
2898 | --- test_json/Queries/converters/jansson/serialize_json_14.xq 2011-08-07 21:55:48 +0000 | |||
2899 | +++ test_json/Queries/converters/jansson/serialize_json_14.xq 1970-01-01 00:00:00 +0000 | |||
2900 | @@ -1,16 +0,0 @@ | |||
2901 | 1 | (: valid json generation: comments should be ignored :) | ||
2902 | 2 | |||
2903 | 3 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2904 | 4 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2905 | 5 | |||
2906 | 6 | declare variable $local:json := | ||
2907 | 7 | <json type="object"> | ||
2908 | 8 | <pair name="servlet" type="object"> | ||
2909 | 9 | <!--comment--> | ||
2910 | 10 | <pair name="name" type="string">value</pair> | ||
2911 | 11 | </pair> | ||
2912 | 12 | </json>; | ||
2913 | 13 | |||
2914 | 14 | json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2915 | 15 | <json-param name="mapping" value="simple-json" /> | ||
2916 | 16 | </options>) | ||
2917 | 17 | 0 | ||
2918 | === removed file 'test_json/Queries/converters/jansson/serialize_json_15.xq' | |||
2919 | --- test_json/Queries/converters/jansson/serialize_json_15.xq 2011-08-07 21:55:48 +0000 | |||
2920 | +++ test_json/Queries/converters/jansson/serialize_json_15.xq 1970-01-01 00:00:00 +0000 | |||
2921 | @@ -1,13 +0,0 @@ | |||
2922 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2923 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2924 | 3 | |||
2925 | 4 | declare variable $local:json :=<json type="object"> | ||
2926 | 5 | <pair name="servlet" type="array"> | ||
2927 | 6 | <item type="object"> | ||
2928 | 7 | </item> | ||
2929 | 8 | </pair> | ||
2930 | 9 | </json>; | ||
2931 | 10 | |||
2932 | 11 | json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2933 | 12 | <json-param name="mapping" value="simple-json" /> | ||
2934 | 13 | </options>) | ||
2935 | 14 | 0 | ||
2936 | === removed file 'test_json/Queries/converters/jansson/serialize_json_16.xq' | |||
2937 | --- test_json/Queries/converters/jansson/serialize_json_16.xq 2011-08-07 21:55:48 +0000 | |||
2938 | +++ test_json/Queries/converters/jansson/serialize_json_16.xq 1970-01-01 00:00:00 +0000 | |||
2939 | @@ -1,14 +0,0 @@ | |||
2940 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2941 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2942 | 3 | |||
2943 | 4 | declare variable $local:json :=<json type="object"> | ||
2944 | 5 | <pair name="servlet" type="array"> | ||
2945 | 6 | <item type="array"> | ||
2946 | 7 | <item type='string'>212 732-1234</item> | ||
2947 | 8 | </item> | ||
2948 | 9 | </pair> | ||
2949 | 10 | </json>; | ||
2950 | 11 | |||
2951 | 12 | json:serialize($local:json,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2952 | 13 | <json-param name="mapping" value="simple-json" /> | ||
2953 | 14 | </options>) | ||
2954 | 15 | 0 | ||
2955 | === removed file 'test_json/Queries/converters/jansson/serialize_json_17.spec' | |||
2956 | --- test_json/Queries/converters/jansson/serialize_json_17.spec 2011-05-31 15:21:09 +0000 | |||
2957 | +++ test_json/Queries/converters/jansson/serialize_json_17.spec 1970-01-01 00:00:00 +0000 | |||
2958 | @@ -1,1 +0,0 @@ | |||
2959 | 1 | Comparison: Ignore | ||
2960 | 2 | \ No newline at end of file | 0 | \ No newline at end of file |
2961 | 3 | 1 | ||
2962 | === removed file 'test_json/Queries/converters/jansson/serialize_json_17.xq' | |||
2963 | --- test_json/Queries/converters/jansson/serialize_json_17.xq 2011-08-07 21:55:48 +0000 | |||
2964 | +++ test_json/Queries/converters/jansson/serialize_json_17.xq 1970-01-01 00:00:00 +0000 | |||
2965 | @@ -1,23 +0,0 @@ | |||
2966 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2967 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2968 | 3 | |||
2969 | 4 | |||
2970 | 5 | declare variable $local:json := | ||
2971 | 6 | '{ "special-chars": { | ||
2972 | 7 | "quote": "\"", | ||
2973 | 8 | "backslash": "\\", | ||
2974 | 9 | "backspace": "\b", | ||
2975 | 10 | "formfeed": "\f", | ||
2976 | 11 | "newline": "\n", | ||
2977 | 12 | "carriage return": "\r", | ||
2978 | 13 | "horizontal tab": "\t", | ||
2979 | 14 | "solidus": "\/" | ||
2980 | 15 | } | ||
2981 | 16 | }'; | ||
2982 | 17 | |||
2983 | 18 | json:serialize((json:parse(($local:json),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2984 | 19 | <json-param name="mapping" value="simple-json" /> | ||
2985 | 20 | </options>)),<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
2986 | 21 | <json-param name="mapping" value="simple-json" /> | ||
2987 | 22 | </options>) | ||
2988 | 23 | |||
2989 | 24 | 0 | ||
2990 | === removed file 'test_json/Queries/converters/jansson/serialize_json_18.xq' | |||
2991 | --- test_json/Queries/converters/jansson/serialize_json_18.xq 2011-10-06 07:40:17 +0000 | |||
2992 | +++ test_json/Queries/converters/jansson/serialize_json_18.xq 1970-01-01 00:00:00 +0000 | |||
2993 | @@ -1,7 +0,0 @@ | |||
2994 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
2995 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
2996 | 3 | |||
2997 | 4 | |||
2998 | 5 | declare 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>; | ||
2999 | 6 | |||
3000 | 7 | json:serialize($tmp) | ||
3001 | 8 | \ No newline at end of file | 0 | \ No newline at end of file |
3002 | 9 | 1 | ||
3003 | === removed file 'test_json/Queries/converters/jansson/serialize_json_ml_01.xq' | |||
3004 | --- test_json/Queries/converters/jansson/serialize_json_ml_01.xq 2011-08-11 20:09:07 +0000 | |||
3005 | +++ test_json/Queries/converters/jansson/serialize_json_ml_01.xq 1970-01-01 00:00:00 +0000 | |||
3006 | @@ -1,12 +0,0 @@ | |||
3007 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
3008 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
3009 | 3 | |||
3010 | 4 | declare variable $tmp :=<ul> | ||
3011 | 5 | <li style="color:red">First Item</li> | ||
3012 | 6 | <li title="Some hover text." style="color:green">Second Item</li> | ||
3013 | 7 | <li><span class="code-example-third">Third</span>Item</li> | ||
3014 | 8 | </ul>; | ||
3015 | 9 | |||
3016 | 10 | json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
3017 | 11 | <json-param name="mapping" value="json-ml" type="array"/> | ||
3018 | 12 | </options>) | ||
3019 | 13 | \ No newline at end of file | 0 | \ No newline at end of file |
3020 | 14 | 1 | ||
3021 | === removed file 'test_json/Queries/converters/jansson/serialize_json_ml_02.xq' | |||
3022 | --- test_json/Queries/converters/jansson/serialize_json_ml_02.xq 2011-08-11 20:09:07 +0000 | |||
3023 | +++ test_json/Queries/converters/jansson/serialize_json_ml_02.xq 1970-01-01 00:00:00 +0000 | |||
3024 | @@ -1,21 +0,0 @@ | |||
3025 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
3026 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
3027 | 3 | |||
3028 | 4 | declare variable $tmp :=<table class="MyTable" style="background-color:yellow"> | ||
3029 | 5 | <tr> | ||
3030 | 6 | <td class="MyTD" style="border:1px solid black">#5D28D1</td> | ||
3031 | 7 | <td class="MyTD" style="background-color:red">Example text here</td> | ||
3032 | 8 | </tr> | ||
3033 | 9 | <tr> | ||
3034 | 10 | <td class="MyTD" style="border:1px solid black">#AF44EF</td> | ||
3035 | 11 | <td class="MyTD" style="background-color:green">127310656</td> | ||
3036 | 12 | </tr> | ||
3037 | 13 | <tr> | ||
3038 | 14 | <td class="MyTD" style="border:1px solid black">#AAD034</td> | ||
3039 | 15 | <td class="MyTD" style="background-color:blue">\u00A0<span style="background-color:maroon">\u00A9</span>\u00A0</td> | ||
3040 | 16 | </tr> | ||
3041 | 17 | </table>; | ||
3042 | 18 | |||
3043 | 19 | json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
3044 | 20 | <json-param name="mapping" value="json-ml" type="array"/> | ||
3045 | 21 | </options>) | ||
3046 | 22 | \ No newline at end of file | 0 | \ No newline at end of file |
3047 | 23 | 1 | ||
3048 | === removed file 'test_json/Queries/converters/jansson/serialize_json_ml_03.spec' | |||
3049 | --- test_json/Queries/converters/jansson/serialize_json_ml_03.spec 2011-08-18 22:09:48 +0000 | |||
3050 | +++ test_json/Queries/converters/jansson/serialize_json_ml_03.spec 1970-01-01 00:00:00 +0000 | |||
3051 | @@ -1,1 +0,0 @@ | |||
3052 | 1 | Error: http://www.zorba-xquery.com/modules/converters/json:InvalidXDM | ||
3053 | 2 | 0 | ||
3054 | === removed file 'test_json/Queries/converters/jansson/serialize_json_ml_03.xq' | |||
3055 | --- test_json/Queries/converters/jansson/serialize_json_ml_03.xq 2011-08-11 20:09:07 +0000 | |||
3056 | +++ test_json/Queries/converters/jansson/serialize_json_ml_03.xq 1970-01-01 00:00:00 +0000 | |||
3057 | @@ -1,8 +0,0 @@ | |||
3058 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
3059 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
3060 | 3 | |||
3061 | 4 | declare variable $tmp :=<!--comment-->; | ||
3062 | 5 | |||
3063 | 6 | json:serialize($tmp,<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options" > | ||
3064 | 7 | <json-param name="mapping" value="json-ml" type="array"/> | ||
3065 | 8 | </options>) | ||
3066 | 9 | \ No newline at end of file | 0 | \ No newline at end of file |
3067 | 10 | 1 | ||
3068 | === removed file 'test_json/Queries/converters/jansson/serialize_json_ml_04.xq' | |||
3069 | --- test_json/Queries/converters/jansson/serialize_json_ml_04.xq 2011-10-06 07:40:17 +0000 | |||
3070 | +++ test_json/Queries/converters/jansson/serialize_json_ml_04.xq 1970-01-01 00:00:00 +0000 | |||
3071 | @@ -1,10 +0,0 @@ | |||
3072 | 1 | import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; | ||
3073 | 2 | import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options"; | ||
3074 | 3 | |||
3075 | 4 | declare variable $tmp :=<ul> | ||
3076 | 5 | <li style="color:red">First Item</li> | ||
3077 | 6 | <li title="Some hover text." style="color:green">Second Item</li> | ||
3078 | 7 | <li><span class="code-example-third">Third</span>Item</li> | ||
3079 | 8 | </ul>; | ||
3080 | 9 | |||
3081 | 10 | json:serialize-ml($tmp) | ||
3082 | 11 | \ No newline at end of file | 0 | \ No newline at end of file |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ remove_ old_json- 2012-01- 23T19-46- 43.722Z/ log.html
Log at: http://