├── .gitignore ├── LICENSE.md ├── Makefile ├── README.md ├── include └── json.hpp ├── json.cpp ├── main.cpp └── test ├── cofax-bad.json ├── cofax.json ├── glossary.json └── object_in_array.json /.gitignore: -------------------------------------------------------------------------------- 1 | main 2 | *~ 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2021 Phil Eaton 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | main: *.cpp ./include/*.hpp 2 | clang++ -g -Wall -std=c++2a -I./include *.cpp -o $@ 3 | 4 | 5 | .PHONY: format 6 | format: *.cpp ./include/*.hpp 7 | clang-format -i $^ 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cpp-json 2 | 3 | A basic JSON parser in modern C++ using only the standard library. 4 | 5 | ### Dependencies and build 6 | 7 | Just a modern Clang like Clang 12 on Fedora 34. 8 | 9 | ``` 10 | $ make 11 | $ ./main '{"a": [1, 2, null, { "c": 129 }]}' 12 | { 13 | "a": [ 14 | 1.000000, 15 | 2.000000, 16 | null, 17 | { 18 | "c": 129.000000 19 | } 20 | ] 21 | } 22 | ``` 23 | 24 | ### Nice error handling 25 | 26 | 27 | ```bash 28 | $ ./main "$(cat ./test/cofax-bad.json)" 29 | Unexpected token ',', type 'Syntax', index 30 | Failed to parse at line 5, column 18 31 | "servlet-class": ,"org.cofax.cds.CDSServlet", 32 | ^ 33 | ``` 34 | 35 | ### API 36 | 37 | Just two main functions. 38 | 39 | #### std::tuple parse(std::string) 40 | 41 | This turns a string into a `json::JSONValue`. If it fails, the second 42 | element in the return tuple contains an error string. 43 | 44 | #### std::string deparse(json::JSONValue) 45 | 46 | This turns a `json::JSONValue` back into a JSON string. 47 | -------------------------------------------------------------------------------- /include/json.hpp: -------------------------------------------------------------------------------- 1 | #ifndef JSON_H 2 | #define JSON_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace json { 11 | enum class JSONValueType { String, Number, Object, Array, Boolean, Null }; 12 | struct JSONValue { 13 | std::optional string; 14 | std::optional number; 15 | std::optional boolean; 16 | std::optional> array; 17 | std::optional> object; 18 | JSONValueType type; 19 | }; 20 | enum class JSONTokenType { String, Number, Syntax, Boolean, Null }; 21 | struct JSONToken { 22 | std::string value; 23 | JSONTokenType type; 24 | int location; 25 | std::shared_ptr full_source; 26 | }; 27 | 28 | std::tuple, std::string> lex(std::string); 29 | std::tuple parse(std::vector, 30 | int index = 0); 31 | std::tuple parse(std::string); 32 | std::string deparse(JSONValue, std::string whitespace = ""); 33 | } // namespace json 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /json.cpp: -------------------------------------------------------------------------------- 1 | #include "json.hpp" 2 | 3 | #include 4 | 5 | namespace json { 6 | std::string JSONTokenType_to_string(JSONTokenType jtt) { 7 | switch (jtt) { 8 | case JSONTokenType::String: 9 | return "String"; 10 | case JSONTokenType::Number: 11 | return "Number"; 12 | case JSONTokenType::Syntax: 13 | return "Syntax"; 14 | case JSONTokenType::Boolean: 15 | return "Boolean"; 16 | case JSONTokenType::Null: 17 | return "Null"; 18 | } 19 | } 20 | 21 | std::string format_error(std::string base, std::string source, int index) { 22 | std::ostringstream s; 23 | int counter = 0; 24 | int line = 1; 25 | int column = 0; 26 | std::string lastline = ""; 27 | std::string whitespace = ""; 28 | for (auto c : source) { 29 | if (counter == index) { 30 | break; 31 | } 32 | 33 | if (c == '\n') { 34 | line++; 35 | column = 0; 36 | lastline = ""; 37 | whitespace = ""; 38 | } else if (c == '\t') { 39 | column++; 40 | lastline += " "; 41 | whitespace += " "; 42 | } else { 43 | column++; 44 | lastline += c; 45 | whitespace += " "; 46 | } 47 | 48 | counter++; 49 | } 50 | 51 | // Continue accumulating the lastline for debugging 52 | while (counter < source.size()) { 53 | auto c = source[counter]; 54 | if (c == '\n') { 55 | break; 56 | } 57 | lastline += c; 58 | counter++; 59 | } 60 | 61 | s << base << " at line " << line << ", column " << column << std::endl; 62 | s << lastline << std::endl; 63 | s << whitespace << "^"; 64 | 65 | return s.str(); 66 | } 67 | 68 | int lex_whitespace(std::string raw_json, int index) { 69 | while (std::isspace(raw_json[index])) { 70 | if (index == raw_json.length()) { 71 | break; 72 | } 73 | 74 | index++; 75 | } 76 | 77 | return index; 78 | } 79 | 80 | std::tuple lex_syntax(std::string raw_json, 81 | int index) { 82 | JSONToken token{"", JSONTokenType::Syntax, index}; 83 | std::string value = ""; 84 | auto c = raw_json[index]; 85 | if (c == '[' || c == ']' || c == '{' || c == '}' || c == ':' || c == ',') { 86 | token.value += c; 87 | index++; 88 | } 89 | 90 | return {token, index, ""}; 91 | } 92 | 93 | std::tuple lex_string(std::string raw_json, 94 | int original_index) { 95 | int index = original_index; 96 | JSONToken token{"", JSONTokenType::String, index}; 97 | std::string value = ""; 98 | auto c = raw_json[index]; 99 | if (c != '"') { 100 | return {token, original_index, ""}; 101 | } 102 | index++; 103 | 104 | // TODO: handle nested quotes 105 | while (c = raw_json[index], c != '"') { 106 | if (index == raw_json.length()) { 107 | return { 108 | token, index, 109 | format_error("Unexpected EOF while lexing string", raw_json, index)}; 110 | } 111 | 112 | token.value += c; 113 | index++; 114 | } 115 | index++; 116 | 117 | return {token, index, ""}; 118 | } 119 | 120 | std::tuple lex_number(std::string raw_json, 121 | int original_index) { 122 | int index = original_index; 123 | JSONToken token = {"", JSONTokenType::Number, index}; 124 | std::string value = ""; 125 | // TODO: handle not just integers 126 | while (true) { 127 | if (index == raw_json.length()) { 128 | break; 129 | } 130 | 131 | auto c = raw_json[index]; 132 | if (!(c >= '0' && c <= '9')) { 133 | break; 134 | } 135 | 136 | token.value += c; 137 | index++; 138 | } 139 | 140 | return {token, index, ""}; 141 | } 142 | 143 | std::tuple lex_keyword(std::string raw_json, 144 | std::string keyword, 145 | JSONTokenType type, 146 | int original_index) { 147 | int index = original_index; 148 | JSONToken token{"", type, index}; 149 | while (keyword[index - original_index] == raw_json[index]) { 150 | if (index == raw_json.length()) { 151 | break; 152 | } 153 | 154 | index++; 155 | } 156 | 157 | if (index - original_index == keyword.length()) { 158 | token.value = keyword; 159 | } 160 | return {token, index, ""}; 161 | } 162 | 163 | std::tuple lex_null(std::string raw_json, 164 | int index) { 165 | return lex_keyword(raw_json, "null", JSONTokenType::Null, index); 166 | } 167 | 168 | std::tuple lex_true(std::string raw_json, 169 | int index) { 170 | return lex_keyword(raw_json, "true", JSONTokenType::Boolean, index); 171 | } 172 | 173 | std::tuple lex_false(std::string raw_json, 174 | int index) { 175 | return lex_keyword(raw_json, "false", JSONTokenType::Boolean, index); 176 | } 177 | 178 | std::tuple, std::string> lex(std::string raw_json) { 179 | std::vector tokens; 180 | auto original_copy = std::make_shared(raw_json); 181 | auto generic_lexers = {lex_syntax, lex_string, lex_number, 182 | lex_null, lex_true, lex_false}; 183 | for (int i = 0; i < raw_json.length(); i++) { 184 | if (auto new_index = lex_whitespace(raw_json, i); i != new_index) { 185 | i = new_index - 1; 186 | continue; 187 | } 188 | 189 | auto found = false; 190 | for (auto lexer : generic_lexers) { 191 | if (auto [token, new_index, error] = lexer(raw_json, i); i != new_index) { 192 | if (error.length()) { 193 | return {{}, error}; 194 | } 195 | 196 | token.full_source = original_copy; 197 | tokens.push_back(token); 198 | i = new_index - 1; 199 | found = true; 200 | break; 201 | } 202 | } 203 | 204 | if (found) { 205 | continue; 206 | } 207 | 208 | return {{}, format_error("Unable to lex", raw_json, i)}; 209 | } 210 | 211 | return {tokens, ""}; 212 | } 213 | 214 | std::string format_parse_error(std::string base, JSONToken token) { 215 | std::ostringstream s; 216 | s << "Unexpected token '" << token.value << "', type '" 217 | << JSONTokenType_to_string(token.type) << "', index "; 218 | s << std::endl << base; 219 | return format_error(s.str(), *token.full_source, token.location); 220 | } 221 | 222 | std::tuple, int, std::string> 223 | parse_array(std::vector tokens, int index) { 224 | std::vector children = {}; 225 | while (index < tokens.size()) { 226 | auto t = tokens[index]; 227 | if (t.type == JSONTokenType::Syntax) { 228 | if (t.value == "]") { 229 | return {children, index + 1, ""}; 230 | } 231 | 232 | if (t.value == ",") { 233 | index++; 234 | t = tokens[index]; 235 | } else if (children.size() > 0) { 236 | return {{}, 237 | index, 238 | format_parse_error("Expected comma after element in array", t)}; 239 | } 240 | } 241 | 242 | auto [child, new_index, error] = parse(tokens, index); 243 | if (error.size()) { 244 | return {{}, index, error}; 245 | } 246 | 247 | children.push_back(child); 248 | index = new_index; 249 | } 250 | 251 | return { 252 | {}, 253 | index, 254 | format_parse_error("Unexpected EOF while parsing array", tokens[index])}; 255 | } 256 | 257 | std::tuple, int, std::string> 258 | parse_object(std::vector tokens, int index) { 259 | std::map values = {}; 260 | while (index < tokens.size()) { 261 | auto t = tokens[index]; 262 | if (t.type == JSONTokenType::Syntax) { 263 | if (t.value == "}") { 264 | return {values, index + 1, ""}; 265 | } 266 | 267 | if (t.value == ",") { 268 | index++; 269 | t = tokens[index]; 270 | } else if (values.size() > 0) { 271 | return { 272 | {}, 273 | index, 274 | format_parse_error("Expected comma after element in object", t)}; 275 | } else { 276 | return {{}, 277 | index, 278 | format_parse_error( 279 | "Expected key-value pair or closing brace in object", t)}; 280 | } 281 | } 282 | 283 | auto [key, new_index, error] = parse(tokens, index); 284 | if (error.size()) { 285 | return {{}, index, error}; 286 | } 287 | 288 | if (key.type != JSONValueType::String) { 289 | return { 290 | {}, index, format_parse_error("Expected string key in object", t)}; 291 | } 292 | index = new_index; 293 | t = tokens[index]; 294 | 295 | if (!(t.type == JSONTokenType::Syntax && t.value == ":")) { 296 | return {{}, 297 | index, 298 | format_parse_error("Expected colon after key in object", t)}; 299 | } 300 | index++; 301 | t = tokens[index]; 302 | 303 | auto [value, new_index1, error1] = parse(tokens, index); 304 | if (error1.size()) { 305 | return {{}, index, error1}; 306 | } 307 | 308 | values[key.string.value()] = value; 309 | index = new_index1; 310 | } 311 | 312 | return {values, index + 1, ""}; 313 | } 314 | 315 | std::tuple parse(std::vector tokens, 316 | int index) { 317 | auto token = tokens[index]; 318 | switch (token.type) { 319 | case JSONTokenType::Number: { 320 | auto n = std::stod(token.value); 321 | return {JSONValue{.number = n, .type = JSONValueType::Number}, index + 1, 322 | ""}; 323 | } 324 | case JSONTokenType::Boolean: 325 | return {JSONValue{.boolean = token.value == "true", 326 | .type = JSONValueType::Boolean}, 327 | index + 1, ""}; 328 | case JSONTokenType::Null: 329 | return {JSONValue{.type = JSONValueType::Null}, index + 1, ""}; 330 | case JSONTokenType::String: 331 | return {JSONValue{.string = token.value, .type = JSONValueType::String}, 332 | index + 1, ""}; 333 | case JSONTokenType::Syntax: 334 | if (token.value == "[") { 335 | auto [array, new_index, error] = parse_array(tokens, index + 1); 336 | return {JSONValue{.array = array, .type = JSONValueType::Array}, 337 | new_index, error}; 338 | } 339 | 340 | if (token.value == "{") { 341 | auto [object, new_index, error] = parse_object(tokens, index + 1); 342 | return {JSONValue{.object = std::optional(object), 343 | .type = JSONValueType::Object}, 344 | new_index, error}; 345 | } 346 | } 347 | 348 | return {{}, index, format_parse_error("Failed to parse", token)}; 349 | } 350 | 351 | std::tuple parse(std::string source) { 352 | auto [tokens, error] = json::lex(source); 353 | if (error.size()) { 354 | return {{}, error}; 355 | } 356 | 357 | auto [ast, _, error1] = json::parse(tokens); 358 | return {ast, error1}; 359 | } 360 | 361 | std::string deparse(JSONValue v, std::string whitespace) { 362 | switch (v.type) { 363 | case JSONValueType::String: 364 | return "\"" + v.string.value() + "\""; 365 | case JSONValueType::Boolean: 366 | return (v.boolean.value() ? "true" : "false"); 367 | case JSONValueType::Number: 368 | return std::to_string(v.number.value()); 369 | case JSONValueType::Null: 370 | return "null"; 371 | case JSONValueType::Array: { 372 | std::string s = "[\n"; 373 | auto a = v.array.value(); 374 | for (int i = 0; i < a.size(); i++) { 375 | auto value = a[i]; 376 | s += whitespace + " " + deparse(value, whitespace + " "); 377 | if (i < a.size() - 1) { 378 | s += ","; 379 | } 380 | 381 | s += "\n"; 382 | } 383 | 384 | return s + whitespace + "]"; 385 | } 386 | case JSONValueType::Object: { 387 | std::string s = "{\n"; 388 | auto values = v.object.value(); 389 | auto i = 0; 390 | for (auto const &[key, value] : values) { 391 | s += whitespace + " " + "\"" + key + 392 | "\": " + deparse(value, whitespace + " "); 393 | 394 | if (i < values.size() - 1) { 395 | s += ","; 396 | } 397 | 398 | s += "\n"; 399 | i++; 400 | } 401 | 402 | return s + whitespace + "}"; 403 | } 404 | } 405 | } 406 | } // namespace json 407 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "json.hpp" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) { 6 | if (argc == 1) { 7 | std::cerr << "Expected JSON input argument to parse" << std::endl; 8 | return 1; 9 | } 10 | 11 | std::string in{argv[1]}; 12 | 13 | auto [ast, error] = json::parse(in); 14 | if (error.size()) { 15 | std::cerr << error << std::endl; 16 | return 1; 17 | } 18 | 19 | std::cout << json::deparse(ast); 20 | } 21 | -------------------------------------------------------------------------------- /test/cofax-bad.json: -------------------------------------------------------------------------------- 1 | {"web-app": { 2 | "servlet": [ 3 | { 4 | "servlet-name": "cofaxCDS", 5 | "servlet-class": ,"org.cofax.cds.CDSServlet", 6 | "init-param": { 7 | "configGlossary:installationAt": "Philadelphia, PA", 8 | "configGlossary:adminEmail": "ksm@pobox.com", 9 | "configGlossary:poweredBy": "Cofax", 10 | "configGlossary:poweredByIcon": "/images/cofax.gif", 11 | "configGlossary:staticPath": "/content/static", 12 | "templateProcessorClass": "org.cofax.WysiwygTemplate", 13 | "templateLoaderClass": "org.cofax.FilesTemplateLoader", 14 | "templatePath": "templates", 15 | "templateOverridePath": "", 16 | "defaultListTemplate": "listTemplate.htm", 17 | "defaultFileTemplate": "articleTemplate.htm", 18 | "useJSP": false, 19 | "jspListTemplate": "listTemplate.jsp", 20 | "jspFileTemplate": "articleTemplate.jsp", 21 | "cachePackageTagsTrack": 200, 22 | "cachePackageTagsStore": 200, 23 | "cachePackageTagsRefresh": 60, 24 | "cacheTemplatesTrack": 100, 25 | "cacheTemplatesStore": 50, 26 | "cacheTemplatesRefresh": 15, 27 | "cachePagesTrack": 200, 28 | "cachePagesStore": 100, 29 | "cachePagesRefresh": 10, 30 | "cachePagesDirtyRead": 10, 31 | "searchEngineListTemplate": "forSearchEnginesList.htm", 32 | "searchEngineFileTemplate": "forSearchEngines.htm", 33 | "searchEngineRobotsDb": "WEB-INF/robots.db", 34 | "useDataStore": true, 35 | "dataStoreClass": "org.cofax.SqlDataStore", 36 | "redirectionClass": "org.cofax.SqlRedirection", 37 | "dataStoreName": "cofax", 38 | "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", 39 | "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", 40 | "dataStoreUser": "sa", 41 | "dataStorePassword": "dataStoreTestQuery", 42 | "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", 43 | "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", 44 | "dataStoreInitConns": 10, 45 | "dataStoreMaxConns": 100, 46 | "dataStoreConnUsageLimit": 100, 47 | "dataStoreLogLevel": "debug", 48 | "maxUrlLength": 500}}, 49 | { 50 | "servlet-name": "cofaxEmail", 51 | "servlet-class": "org.cofax.cds.EmailServlet", 52 | "init-param": { 53 | "mailHost": "mail1", 54 | "mailHostOverride": "mail2"}}, 55 | { 56 | "servlet-name": "cofaxAdmin", 57 | "servlet-class": "org.cofax.cds.AdminServlet"}, 58 | 59 | { 60 | "servlet-name": "fileServlet", 61 | "servlet-class": "org.cofax.cds.FileServlet"}, 62 | { 63 | "servlet-name": "cofaxTools", 64 | "servlet-class": "org.cofax.cms.CofaxToolsServlet", 65 | "init-param": { 66 | "templatePath": "toolstemplates/", 67 | "log": 1, 68 | "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", 69 | "logMaxSize": "", 70 | "dataLog": 1, 71 | "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", 72 | "dataLogMaxSize": "", 73 | "removePageCache": "/content/admin/remove?cache=pages&id=", 74 | "removeTemplateCache": "/content/admin/remove?cache=templates&id=", 75 | "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", 76 | "lookInContext": 1, 77 | "adminGroupID": 4, 78 | "betaServer": true}}], 79 | "servlet-mapping": { 80 | "cofaxCDS": "/", 81 | "cofaxEmail": "/cofaxutil/aemail/*", 82 | "cofaxAdmin": "/admin/*", 83 | "fileServlet": "/static/*", 84 | "cofaxTools": "/tools/*"}, 85 | 86 | "taglib": { 87 | "taglib-uri": "cofax.tld", 88 | "taglib-location": "/WEB-INF/tlds/cofax.tld"}}} 89 | -------------------------------------------------------------------------------- /test/cofax.json: -------------------------------------------------------------------------------- 1 | {"web-app": { 2 | "servlet": [ 3 | { 4 | "servlet-name": "cofaxCDS", 5 | "servlet-class": "org.cofax.cds.CDSServlet", 6 | "init-param": { 7 | "configGlossary:installationAt": "Philadelphia, PA", 8 | "configGlossary:adminEmail": "ksm@pobox.com", 9 | "configGlossary:poweredBy": "Cofax", 10 | "configGlossary:poweredByIcon": "/images/cofax.gif", 11 | "configGlossary:staticPath": "/content/static", 12 | "templateProcessorClass": "org.cofax.WysiwygTemplate", 13 | "templateLoaderClass": "org.cofax.FilesTemplateLoader", 14 | "templatePath": "templates", 15 | "templateOverridePath": "", 16 | "defaultListTemplate": "listTemplate.htm", 17 | "defaultFileTemplate": "articleTemplate.htm", 18 | "useJSP": false, 19 | "jspListTemplate": "listTemplate.jsp", 20 | "jspFileTemplate": "articleTemplate.jsp", 21 | "cachePackageTagsTrack": 200, 22 | "cachePackageTagsStore": 200, 23 | "cachePackageTagsRefresh": 60, 24 | "cacheTemplatesTrack": 100, 25 | "cacheTemplatesStore": 50, 26 | "cacheTemplatesRefresh": 15, 27 | "cachePagesTrack": 200, 28 | "cachePagesStore": 100, 29 | "cachePagesRefresh": 10, 30 | "cachePagesDirtyRead": 10, 31 | "searchEngineListTemplate": "forSearchEnginesList.htm", 32 | "searchEngineFileTemplate": "forSearchEngines.htm", 33 | "searchEngineRobotsDb": "WEB-INF/robots.db", 34 | "useDataStore": true, 35 | "dataStoreClass": "org.cofax.SqlDataStore", 36 | "redirectionClass": "org.cofax.SqlRedirection", 37 | "dataStoreName": "cofax", 38 | "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", 39 | "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", 40 | "dataStoreUser": "sa", 41 | "dataStorePassword": "dataStoreTestQuery", 42 | "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", 43 | "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", 44 | "dataStoreInitConns": 10, 45 | "dataStoreMaxConns": 100, 46 | "dataStoreConnUsageLimit": 100, 47 | "dataStoreLogLevel": "debug", 48 | "maxUrlLength": 500}}, 49 | { 50 | "servlet-name": "cofaxEmail", 51 | "servlet-class": "org.cofax.cds.EmailServlet", 52 | "init-param": { 53 | "mailHost": "mail1", 54 | "mailHostOverride": "mail2"}}, 55 | { 56 | "servlet-name": "cofaxAdmin", 57 | "servlet-class": "org.cofax.cds.AdminServlet"}, 58 | 59 | { 60 | "servlet-name": "fileServlet", 61 | "servlet-class": "org.cofax.cds.FileServlet"}, 62 | { 63 | "servlet-name": "cofaxTools", 64 | "servlet-class": "org.cofax.cms.CofaxToolsServlet", 65 | "init-param": { 66 | "templatePath": "toolstemplates/", 67 | "log": 1, 68 | "logLocation": "/usr/local/tomcat/logs/CofaxTools.log", 69 | "logMaxSize": "", 70 | "dataLog": 1, 71 | "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", 72 | "dataLogMaxSize": "", 73 | "removePageCache": "/content/admin/remove?cache=pages&id=", 74 | "removeTemplateCache": "/content/admin/remove?cache=templates&id=", 75 | "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", 76 | "lookInContext": 1, 77 | "adminGroupID": 4, 78 | "betaServer": true}}], 79 | "servlet-mapping": { 80 | "cofaxCDS": "/", 81 | "cofaxEmail": "/cofaxutil/aemail/*", 82 | "cofaxAdmin": "/admin/*", 83 | "fileServlet": "/static/*", 84 | "cofaxTools": "/tools/*"}, 85 | 86 | "taglib": { 87 | "taglib-uri": "cofax.tld", 88 | "taglib-location": "/WEB-INF/tlds/cofax.tld"}}} 89 | -------------------------------------------------------------------------------- /test/glossary.json: -------------------------------------------------------------------------------- 1 | { 2 | "glossary": { 3 | "title": "example glossary", 4 | "GlossDiv": { 5 | "title": "S", 6 | "GlossList": { 7 | "GlossEntry": { 8 | "ID": "SGML", 9 | "SortAs": "SGML", 10 | "GlossTerm": "Standard Generalized Markup Language", 11 | "Acronym": "SGML", 12 | "Abbrev": "ISO 8879:1986", 13 | "GlossDef": { 14 | "para": "A meta-markup language, used to create markup languages such as DocBook.", 15 | "GlossSeeAlso": ["GML", "XML"] 16 | }, 17 | "GlossSee": "markup" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/object_in_array.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": [{ "b": 1 }] 3 | } 4 | --------------------------------------------------------------------------------