1 /* 2 * Copyright (c) 2009-2016 Petri Lehtinen <petri@digip.org> 3 * 4 * Jansson is free software; you can redistribute it and/or modify 5 * it under the terms of the MIT license. See LICENSE for details. 6 */ 7 /** 8 * License: MIT 9 */ 10 module jansson_d.jansson; 11 12 13 private static import core.stdc.config; 14 private static import core.stdc.stdio; 15 private static import jansson_d.dump; 16 private static import jansson_d.hashtable_seed; 17 private static import jansson_d.jansson_config; 18 private static import jansson_d.load; 19 private static import jansson_d.memory; 20 private static import jansson_d.pack_unpack; 21 private static import jansson_d.value; 22 private static import jansson_d.version_; 23 24 /* version */ 25 26 /// 27 public enum JANSSON_MAJOR_VERSION = 2; 28 29 /// 30 public enum JANSSON_MINOR_VERSION = 13; 31 32 /// 33 public enum JANSSON_MICRO_VERSION = 1; 34 35 /* Micro version is omitted if it's 0 */ 36 /// 37 public enum JANSSON_VERSION = "2.13.1"; 38 39 /** 40 * Version as a 3-byte hex number, e.g. 0x010201 == 1.2.1. Use this 41 * for numeric comparisons, e.g. #if JANSSON_VERSION_HEX >= ... 42 */ 43 public enum JANSSON_VERSION_HEX = (.JANSSON_MAJOR_VERSION << 16) | (.JANSSON_MINOR_VERSION << 8) | (.JANSSON_MICRO_VERSION << 0); 44 45 /* 46 * If __atomic or __sync builtins are available the library is thread 47 * safe for all read-only functions plus reference counting. 48 */ 49 static if ((jansson_d.jansson_config.JSON_HAVE_ATOMIC_BUILTINS) || (jansson_d.jansson_config.JSON_HAVE_SYNC_BUILTINS)) { 50 enum JANSSON_THREAD_SAFE_REFCOUNT = 1; 51 } 52 53 //#if (defined(__GNUC__)) || (defined(__clang__)) 54 //#define JANSSON_ATTRS(x) __attribute__(x) 55 //#else 56 //#define JANSSON_ATTRS(x) 57 //#endif 58 59 /* types */ 60 61 /// 62 public enum json_type 63 { 64 JSON_OBJECT, 65 JSON_ARRAY, 66 JSON_STRING, 67 JSON_INTEGER, 68 JSON_REAL, 69 JSON_TRUE, 70 JSON_FALSE, 71 JSON_NULL, 72 } 73 74 //Declaration name in C language 75 public enum 76 { 77 JSON_OBJECT = .json_type.JSON_OBJECT, 78 JSON_ARRAY = .json_type.JSON_ARRAY, 79 JSON_STRING = .json_type.JSON_STRING, 80 JSON_INTEGER = .json_type.JSON_INTEGER, 81 JSON_REAL = .json_type.JSON_REAL, 82 JSON_TRUE = .json_type.JSON_TRUE, 83 JSON_FALSE = .json_type.JSON_FALSE, 84 JSON_NULL = .json_type.JSON_NULL, 85 } 86 87 /// 88 extern (C) 89 public struct json_t 90 { 91 json_type type = cast(.json_type)(0); 92 93 /* volatile */ 94 size_t refcount; 95 } 96 97 /* disabled if using cmake */ 98 //version (JANSSON_USING_CMAKE) { 99 version (all) { 100 /// 101 public enum JSON_INTEGER_FORMAT = "lld"; 102 103 /// 104 public alias json_int_t = long; 105 106 static assert(jansson_d.jansson_config.JSON_INTEGER_IS_LONG_LONG); 107 } else { 108 static if (jansson_d.jansson_config.JSON_INTEGER_IS_LONG_LONG) { 109 //version (Windows) { 110 version (none) { 111 public enum JSON_INTEGER_FORMAT = "I64d"; 112 } else { 113 public enum JSON_INTEGER_FORMAT = "lld"; 114 } 115 116 version (none) { 117 public alias json_int_t = core.stdc.config.cpp_longlong; 118 } else { 119 public alias json_int_t = long; 120 } 121 } else { 122 enum JSON_INTEGER_FORMAT = "ld"; 123 public alias json_int_t = core.stdc.config.c_long; 124 } 125 } 126 127 /// 128 public template json_typeof(string json) 129 { 130 enum json_typeof = "((" ~ json ~ ").type)"; 131 } 132 133 /// 134 public template json_is_object(string json) 135 { 136 enum json_is_object = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_OBJECT))"; 137 } 138 139 /// 140 public template json_is_array(string json) 141 { 142 enum json_is_array = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_ARRAY))"; 143 } 144 145 /// 146 public template json_is_string(string json) 147 { 148 enum json_is_string = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_STRING))"; 149 } 150 151 /// 152 public template json_is_integer(string json) 153 { 154 enum json_is_integer = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_INTEGER))"; 155 } 156 157 /// 158 public template json_is_real(string json) 159 { 160 enum json_is_real = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_REAL))"; 161 } 162 163 /// 164 public template json_is_number(string json) 165 { 166 enum json_is_number = "((mixin (jansson_d.jansson.json_is_integer!(\"" ~ json ~ "\"))) || (mixin (jansson_d.jansson.json_is_real!(\"" ~ json ~ "\"))))"; 167 } 168 169 /// 170 public template json_is_true(string json) 171 { 172 enum json_is_true = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_TRUE))"; 173 } 174 175 /// 176 public template json_is_false(string json) 177 { 178 enum json_is_false = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_FALSE))"; 179 } 180 181 /// 182 public alias json_boolean_value = .json_is_true; 183 184 /// 185 public template json_is_boolean(string json) 186 { 187 enum json_is_boolean = "((mixin (jansson_d.jansson.json_is_true!(\"" ~ json ~ "\"))) || (mixin (jansson_d.jansson.json_is_false!(\"" ~ json ~ "\"))))"; 188 } 189 190 /// 191 public template json_is_null(string json) 192 { 193 enum json_is_null = "((" ~ json ~ " != null) && (mixin (jansson_d.jansson.json_typeof!(\"" ~ json ~ "\")) == jansson_d.jansson.json_type.JSON_NULL))"; 194 } 195 196 197 /* construction, destruction, reference counting */ 198 199 /// 200 public alias json_object = jansson_d.value.json_object; 201 202 /// 203 public alias json_array = jansson_d.value.json_array; 204 205 /// 206 public alias json_string = jansson_d.value.json_string; 207 208 /// 209 public alias json_stringn = jansson_d.value.json_stringn; 210 211 /// 212 public alias json_string_nocheck = jansson_d.value.json_string_nocheck; 213 214 /// 215 public alias json_stringn_nocheck = jansson_d.value.json_stringn_nocheck; 216 217 /// 218 public alias json_integer = jansson_d.value.json_integer; 219 220 /// 221 public alias json_real = jansson_d.value.json_real; 222 223 /// 224 public alias json_true = jansson_d.value.json_true; 225 226 /// 227 public alias json_false = jansson_d.value.json_false; 228 229 /// 230 public template json_boolean(string val) 231 { 232 enum json_boolean = "((" ~ val ~ ") ? (jansson_d.value.json_true()) : (jansson_d.value.json_false()))"; 233 } 234 235 /// 236 public alias json_null = jansson_d.value.json_null; 237 238 /* do not call JSON_INTERNAL_INCREF or JSON_INTERNAL_DECREF directly */ 239 static if (jansson_d.jansson_config.JSON_HAVE_ATOMIC_BUILTINS) { 240 //#define JSON_INTERNAL_INCREF(json) __atomic_add_fetch(&json.refcount, 1, __ATOMIC_ACQUIRE) 241 //#define JSON_INTERNAL_DECREF(json) __atomic_sub_fetch(&json.refcount, 1, __ATOMIC_RELEASE) 242 static assert(false); 243 } else static if (jansson_d.jansson_config.JSON_HAVE_SYNC_BUILTINS) { 244 //#define JSON_INTERNAL_INCREF(json) __sync_add_and_fetch(&json.refcount, 1) 245 //#define JSON_INTERNAL_DECREF(json) __sync_sub_and_fetch(&json.refcount, 1) 246 static assert(false); 247 } else { 248 template JSON_INTERNAL_INCREF(string json) 249 { 250 enum JSON_INTERNAL_INCREF = "(++" ~ json ~ ".refcount);"; 251 } 252 253 template JSON_INTERNAL_DECREF(string json) 254 { 255 enum JSON_INTERNAL_DECREF = "(--" ~ json ~ ".refcount);"; 256 } 257 } 258 259 /// 260 pragma(inline, true) 261 pure nothrow @trusted @nogc @live 262 public .json_t* json_incref(scope .json_t* json) 263 264 do 265 { 266 if ((json != null) && (json.refcount != size_t.max)) { 267 mixin (.JSON_INTERNAL_INCREF!("json")); 268 } 269 270 return json; 271 } 272 273 /** do not call json_delete directly */ 274 public alias json_delete = jansson_d.value.json_delete; 275 276 /// 277 pragma(inline, true) 278 nothrow @trusted @nogc 279 public void json_decref(scope .json_t* json) 280 281 do 282 { 283 if ((json != null) && (json.refcount != size_t.max)) { 284 mixin (.JSON_INTERNAL_DECREF!("json")); 285 286 if (json.refcount == 0) { 287 jansson_d.value.json_delete(json); 288 } 289 } 290 } 291 292 //#if (defined(__GNUC__)) || (defined(__clang__)) 293 /* 294 pragma(inline, true) 295 static void json_decrefp(.json_t** json) 296 297 do 298 { 299 if (json != null) { 300 .json_decref(*json); 301 *json = null; 302 } 303 } 304 */ 305 306 //#define json_auto_t .json_t __attribute__((cleanup(.json_decrefp))) 307 //#endif 308 309 /* error reporting */ 310 311 /// 312 public enum JSON_ERROR_TEXT_LENGTH = 160; 313 314 /// 315 public enum JSON_ERROR_SOURCE_LENGTH = 80; 316 317 /// 318 extern (C) 319 public struct json_error_t 320 { 321 int line; 322 int column; 323 int position; 324 char[.JSON_ERROR_SOURCE_LENGTH] source = '\0'; 325 char[.JSON_ERROR_TEXT_LENGTH] text = '\0'; 326 } 327 328 /// 329 public enum json_error_code_t 330 { 331 json_error_unknown, 332 json_error_out_of_memory, 333 json_error_stack_overflow, 334 json_error_cannot_open_file, 335 json_error_invalid_argument, 336 json_error_invalid_utf8, 337 json_error_premature_end_of_input, 338 json_error_end_of_input_expected, 339 json_error_invalid_syntax, 340 json_error_invalid_format, 341 json_error_wrong_type, 342 json_error_null_character, 343 json_error_null_value, 344 json_error_null_byte_in_key, 345 json_error_duplicate_key, 346 json_error_numeric_overflow, 347 json_error_item_not_found, 348 json_error_index_out_of_range, 349 } 350 351 //Declaration name in C language 352 public enum 353 { 354 json_error_unknown = .json_error_code_t.json_error_unknown, 355 json_error_out_of_memory = .json_error_code_t.json_error_out_of_memory, 356 json_error_stack_overflow = .json_error_code_t.json_error_stack_overflow, 357 json_error_cannot_open_file = .json_error_code_t.json_error_cannot_open_file, 358 json_error_invalid_argument = .json_error_code_t.json_error_invalid_argument, 359 json_error_invalid_utf8 = .json_error_code_t.json_error_invalid_utf8, 360 json_error_premature_end_of_input = .json_error_code_t.json_error_premature_end_of_input, 361 json_error_end_of_input_expected = .json_error_code_t.json_error_end_of_input_expected, 362 json_error_invalid_syntax = .json_error_code_t.json_error_invalid_syntax, 363 json_error_invalid_format = .json_error_code_t.json_error_invalid_format, 364 json_error_wrong_type = .json_error_code_t.json_error_wrong_type, 365 json_error_null_character = .json_error_code_t.json_error_null_character, 366 json_error_null_value = .json_error_code_t.json_error_null_value, 367 json_error_null_byte_in_key = .json_error_code_t.json_error_null_byte_in_key, 368 json_error_duplicate_key = .json_error_code_t.json_error_duplicate_key, 369 json_error_numeric_overflow = .json_error_code_t.json_error_numeric_overflow, 370 json_error_item_not_found = .json_error_code_t.json_error_item_not_found, 371 json_error_index_out_of_range = .json_error_code_t.json_error_index_out_of_range, 372 } 373 374 /// 375 pragma(inline, true) 376 pure nothrow @trusted @nogc @live 377 public .json_error_code_t json_error_code(scope const .json_error_t* e) 378 379 in 380 { 381 assert(e != null); 382 } 383 384 do 385 { 386 return cast(.json_error_code_t)(e.text[e.text.length - 1]); 387 } 388 389 /* getters, setters, manipulation */ 390 391 /// 392 public alias json_object_seed = jansson_d.hashtable_seed.json_object_seed; 393 394 /// 395 public alias json_object_size = jansson_d.value.json_object_size; 396 397 /// 398 public alias json_object_get = jansson_d.value.json_object_get; 399 400 /// 401 public alias json_object_getn = jansson_d.value.json_object_getn; 402 403 /// 404 public alias json_object_set_new = jansson_d.value.json_object_set_new; 405 406 /// 407 public alias json_object_setn_new = jansson_d.value.json_object_setn_new; 408 409 /// 410 public alias json_object_set_new_nocheck = jansson_d.value.json_object_set_new_nocheck; 411 412 /// 413 public alias json_object_setn_new_nocheck = jansson_d.value.json_object_setn_new_nocheck; 414 415 /// 416 public alias json_object_del = jansson_d.value.json_object_del; 417 418 /// 419 public alias json_object_deln = jansson_d.value.json_object_deln; 420 421 /// 422 public alias json_object_clear = jansson_d.value.json_object_clear; 423 424 /// 425 public alias json_object_update = jansson_d.value.json_object_update; 426 427 /// 428 public alias json_object_update_existing = jansson_d.value.json_object_update_existing; 429 430 /// 431 public alias json_object_update_missing = jansson_d.value.json_object_update_missing; 432 433 /// 434 public alias json_object_update_recursive = jansson_d.value.json_object_update_recursive; 435 436 /// 437 public alias json_object_iter = jansson_d.value.json_object_iter; 438 439 /// 440 public alias json_object_iter_at = jansson_d.value.json_object_iter_at; 441 442 /// 443 public alias json_object_key_to_iter = jansson_d.value.json_object_key_to_iter; 444 445 /// 446 public alias json_object_iter_next = jansson_d.value.json_object_iter_next; 447 448 /// 449 public alias json_object_iter_key = jansson_d.value.json_object_iter_key; 450 451 /// 452 public alias json_object_iter_key_len = jansson_d.value.json_object_iter_key_len; 453 454 /// 455 public alias json_object_iter_value = jansson_d.value.json_object_iter_value; 456 457 /// 458 public alias json_object_iter_set_new = jansson_d.value.json_object_iter_set_new; 459 460 //#define json_object_foreach(object, key, value) for (key = jansson_d.value.json_object_iter_key(jansson_d.value.json_object_iter(object)); (key) && (value = jansson_d.value.json_object_iter_value(jansson_d.value.json_object_key_to_iter(key))); key = jansson_d.value.json_object_iter_key(jansson_d.value.json_object_iter_next(object, jansson_d.value.json_object_key_to_iter(key)))) 461 462 //#define json_object_keylen_foreach(object, key, key_len, value) for (key = jansson_d.value.json_object_iter_key(jansson_d.value.json_object_iter(object)), key_len = jansson_d.value.json_object_iter_key_len(jansson_d.value.json_object_key_to_iter(key)); (key) && (value = jansson_d.value.json_object_iter_value(jansson_d.value.json_object_key_to_iter(key))); key = jansson_d.value.json_object_iter_key(jansson_d.value.json_object_iter_next(object, jansson_d.value.json_object_key_to_iter(key))), key_len = jansson_d.value.json_object_iter_key_len(jansson_d.value.json_object_key_to_iter(key))) 463 464 //#define json_object_foreach_safe(object, n, key, value) for (key = jansson_d.value.json_object_iter_key(jansson_d.value.json_object_iter(object)), n = jansson_d.value.json_object_iter_next(object, jansson_d.value.json_object_key_to_iter(key)); (key) && (value = jansson_d.value.json_object_iter_value(jansson_d.value.json_object_key_to_iter(key))); key = jansson_d.value.json_object_iter_key(n), n = jansson_d.value.json_object_iter_next(object, jansson_d.value.json_object_key_to_iter(key))) 465 466 //#define json_object_keylen_foreach_safe(object, n, key, key_len, value) for (key = jansson_d.value.json_object_iter_key(jansson_d.value.json_object_iter(object)), n = jansson_d.value.json_object_iter_next(object, jansson_d.value.json_object_key_to_iter(key)), key_len = jansson_d.value.json_object_iter_key_len(jansson_d.value.json_object_key_to_iter(key)); (key) && (value = jansson_d.value.json_object_iter_value(jansson_d.value.json_object_key_to_iter(key))); key = jansson_d.value.json_object_iter_key(n), key_len = jansson_d.value.json_object_iter_key_len(n), n = jansson_d.value.json_object_iter_next(object, jansson_d.value.json_object_key_to_iter(key))) 467 468 //#define json_array_foreach(array, index, value) for (index = 0; (index < jansson_d.value.json_array_size(array)) && (value = jansson_d.value.json_array_get(array, index)); index++) 469 470 /// 471 pragma(inline, true) 472 nothrow @trusted @nogc 473 public int json_object_set(scope .json_t* object, scope const char* key, scope .json_t* value) 474 475 do 476 { 477 return jansson_d.value.json_object_set_new(object, key, .json_incref(value)); 478 } 479 480 /// 481 pragma(inline, true) 482 nothrow @trusted @nogc 483 public int json_object_setn(scope .json_t* object, scope const char* key, size_t key_len, scope .json_t* value) 484 485 do 486 { 487 return jansson_d.value.json_object_setn_new(object, key, key_len, .json_incref(value)); 488 } 489 490 /// 491 pragma(inline, true) 492 nothrow @trusted @nogc 493 public int json_object_set_nocheck(scope .json_t* object, scope const char* key, scope .json_t* value) 494 495 do 496 { 497 return jansson_d.value.json_object_set_new_nocheck(object, key, .json_incref(value)); 498 } 499 500 /// 501 pragma(inline, true) 502 nothrow @trusted @nogc 503 public int json_object_setn_nocheck(scope .json_t* object, scope const char* key, size_t key_len, scope .json_t* value) 504 505 do 506 { 507 return jansson_d.value.json_object_setn_new_nocheck(object, key, key_len, .json_incref(value)); 508 } 509 510 /// 511 pragma(inline, true) 512 nothrow @trusted @nogc 513 public int json_object_iter_set(scope .json_t* object, scope void* iter, scope .json_t* value) 514 515 do 516 { 517 return jansson_d.value.json_object_iter_set_new(object, iter, .json_incref(value)); 518 } 519 520 /// 521 pragma(inline, true) 522 nothrow @trusted @nogc 523 public int json_object_update_new(scope .json_t* object, scope .json_t* other) 524 525 do 526 { 527 int ret = jansson_d.value.json_object_update(object, other); 528 .json_decref(other); 529 530 return ret; 531 } 532 533 /// 534 pragma(inline, true) 535 nothrow @trusted @nogc 536 public int json_object_update_existing_new(scope .json_t* object, scope .json_t* other) 537 538 do 539 { 540 int ret = jansson_d.value.json_object_update_existing(object, other); 541 .json_decref(other); 542 543 return ret; 544 } 545 546 /// 547 pragma(inline, true) 548 nothrow @trusted @nogc 549 public int json_object_update_missing_new(scope .json_t* object, scope .json_t* other) 550 551 do 552 { 553 int ret = jansson_d.value.json_object_update_missing(object, other); 554 .json_decref(other); 555 556 return ret; 557 } 558 559 /// 560 public alias json_array_size = jansson_d.value.json_array_size; 561 562 /// 563 public alias json_array_get = jansson_d.value.json_array_get; 564 565 /// 566 public alias json_array_set_new = jansson_d.value.json_array_set_new; 567 568 /// 569 public alias json_array_append_new = jansson_d.value.json_array_append_new; 570 571 /// 572 public alias json_array_insert_new = jansson_d.value.json_array_insert_new; 573 574 /// 575 public alias json_array_remove = jansson_d.value.json_array_remove; 576 577 /// 578 public alias json_array_clear = jansson_d.value.json_array_clear; 579 580 /// 581 public alias json_array_extend = jansson_d.value.json_array_extend; 582 583 /// 584 pragma(inline, true) 585 nothrow @trusted @nogc 586 public int json_array_set(scope jansson_d.jansson.json_t* array, size_t ind, scope jansson_d.jansson.json_t* value) 587 588 do 589 { 590 return jansson_d.value.json_array_set_new(array, ind, .json_incref(value)); 591 } 592 593 /// 594 pragma(inline, true) 595 nothrow @trusted @nogc 596 public int json_array_append(scope .json_t* array, scope .json_t* value) 597 598 do 599 { 600 return jansson_d.value.json_array_append_new(array, .json_incref(value)); 601 } 602 603 /// 604 pragma(inline, true) 605 nothrow @trusted @nogc 606 public int json_array_insert(scope .json_t* array, size_t ind, scope .json_t* value) 607 608 do 609 { 610 return jansson_d.value.json_array_insert_new(array, ind, .json_incref(value)); 611 } 612 613 /// 614 public alias json_string_value = jansson_d.value.json_string_value; 615 616 /// 617 public alias json_string_length = jansson_d.value.json_string_length; 618 619 /// 620 public alias json_integer_value = jansson_d.value.json_integer_value; 621 622 /// 623 public alias json_real_value = jansson_d.value.json_real_value; 624 625 /// 626 public alias json_number_value = jansson_d.value.json_number_value; 627 628 /// 629 public alias json_string_set = jansson_d.value.json_string_set; 630 631 /// 632 public alias json_string_setn = jansson_d.value.json_string_setn; 633 634 /// 635 public alias json_string_set_nocheck = jansson_d.value.json_string_set_nocheck; 636 637 /// 638 public alias json_string_setn_nocheck = jansson_d.value.json_string_setn_nocheck; 639 640 /// 641 public alias json_integer_set = jansson_d.value.json_integer_set; 642 643 /// 644 public alias json_real_set = jansson_d.value.json_real_set; 645 646 /* pack, unpack */ 647 648 /// 649 //.JANSSON_ATTRS((warn_unused_result)); 650 public alias json_pack = jansson_d.pack_unpack.json_pack; 651 652 /// 653 //.JANSSON_ATTRS((warn_unused_result)); 654 public alias json_pack_ex = jansson_d.pack_unpack.json_pack_ex; 655 656 /// 657 //.JANSSON_ATTRS((warn_unused_result)); 658 public alias json_vpack_ex = jansson_d.pack_unpack.json_vpack_ex; 659 660 /// 661 public enum JSON_VALIDATE_ONLY = 0x01; 662 663 /// 664 public enum JSON_STRICT = 0x02; 665 666 /// 667 public alias json_unpack = jansson_d.pack_unpack.json_unpack; 668 669 /// 670 public alias json_unpack_ex = jansson_d.pack_unpack.json_unpack_ex; 671 672 /// 673 public alias json_vunpack_ex = jansson_d.pack_unpack.json_vunpack_ex; 674 675 /* sprintf */ 676 677 /// 678 public alias json_sprintf = jansson_d.value.json_sprintf; 679 680 /// 681 public alias json_vsprintf = jansson_d.value.json_vsprintf; 682 683 /* equality */ 684 685 /// 686 public alias json_equal = jansson_d.value.json_equal; 687 688 /* copying */ 689 690 /// 691 public alias json_copy = jansson_d.value.json_copy; 692 693 /// 694 public alias json_deep_copy = jansson_d.value.json_deep_copy; 695 696 /* decoding */ 697 698 /// 699 public enum JSON_REJECT_DUPLICATES = 0x01; 700 701 /// 702 public enum JSON_DISABLE_EOF_CHECK = 0x02; 703 704 /// 705 public enum JSON_DECODE_ANY = 0x04; 706 707 /// 708 public enum JSON_DECODE_INT_AS_REAL = 0x08; 709 710 /// 711 public enum JSON_ALLOW_NUL = 0x10; 712 713 /// 714 public alias json_load_callback_t = extern (C) nothrow @nogc size_t function(scope void* buffer, size_t buflen, scope void* data); 715 716 /// 717 public alias json_loads = jansson_d.load.json_loads; 718 719 /// 720 public alias json_loadb = jansson_d.load.json_loadb; 721 722 /// 723 public alias json_loadf = jansson_d.load.json_loadf; 724 725 /// 726 public alias json_loadfd = jansson_d.load.json_loadfd; 727 728 /// 729 public alias json_load_file = jansson_d.load.json_load_file; 730 731 /// 732 public alias json_load_callback = jansson_d.load.json_load_callback; 733 734 /* encoding */ 735 736 /// 737 public enum JSON_MAX_INDENT = 0x1F; 738 739 /// 740 public template JSON_INDENT(string n) 741 { 742 enum JSON_INDENT = "((" ~ n ~ ") & jansson_d.jansson.JSON_MAX_INDENT)"; 743 } 744 745 /// 746 public enum JSON_COMPACT = 0x20; 747 748 /// 749 public enum JSON_ENSURE_ASCII = 0x40; 750 751 /// 752 public enum JSON_SORT_KEYS = 0x80; 753 754 /// 755 public enum JSON_PRESERVE_ORDER = 0x0100; 756 757 /// 758 public enum JSON_ENCODE_ANY = 0x0200; 759 760 /// 761 public enum JSON_ESCAPE_SLASH = 0x0400; 762 763 /// 764 public template JSON_REAL_PRECISION(string n) 765 { 766 enum JSON_REAL_PRECISION = "(((" ~ n ~ ") & 0x1F) << 11)"; 767 } 768 769 /// 770 public enum JSON_EMBED = 0x010000; 771 772 /// 773 public alias json_dump_callback_t = extern (C) nothrow @nogc @live int function(scope const char* buffer, size_t size, void* data); 774 775 /// 776 public alias json_dumps = jansson_d.dump.json_dumps; 777 778 /// 779 public alias json_dumpb = jansson_d.dump.json_dumpb; 780 781 /// 782 public alias json_dumpf = jansson_d.dump.json_dumpf; 783 784 /// 785 public alias json_dumpfd = jansson_d.dump.json_dumpfd; 786 787 /// 788 public alias json_dump_file = jansson_d.dump.json_dump_file; 789 790 /// 791 public alias json_dump_callback = jansson_d.dump.json_dump_callback; 792 793 /* custom memory allocation */ 794 795 /// 796 public alias json_malloc_t = extern (C) nothrow @nogc void* function(size_t); 797 798 /// 799 public alias json_free_t = extern (C) nothrow @nogc void function(void*); 800 801 /// 802 public alias json_set_alloc_funcs = jansson_d.memory.json_set_alloc_funcs; 803 804 /// 805 public alias json_get_alloc_funcs = jansson_d.memory.json_get_alloc_funcs; 806 807 /* runtime version checking */ 808 /// 809 public alias jansson_version_str = jansson_d.version_.jansson_version_str; 810 811 /// 812 public alias jansson_version_cmp = jansson_d.version_.jansson_version_cmp;