filter.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2023, Benoit BLANCHON
  3. // MIT License
  4. #define ARDUINOJSON_ENABLE_COMMENTS 1
  5. #include <ArduinoJson.h>
  6. #include <catch.hpp>
  7. #include <sstream>
  8. #include <string>
  9. TEST_CASE("Filtering") {
  10. struct TestCase {
  11. const char* input;
  12. const char* filter;
  13. uint8_t nestingLimit;
  14. DeserializationError error;
  15. const char* output;
  16. size_t memoryUsage;
  17. };
  18. // clang-format off
  19. TestCase testCases[] = {
  20. {
  21. "{\"hello\":\"world\"}", // 1. input
  22. "null", // 2. filter
  23. 10, // 3. nestingLimit
  24. DeserializationError::Ok, // 4. error
  25. "null", // 5. output
  26. 0 // 6. memoryUsage
  27. },
  28. {
  29. "{\"hello\":\"world\"}",
  30. "false",
  31. 10,
  32. DeserializationError::Ok,
  33. "null",
  34. 0
  35. },
  36. {
  37. "{\"abcdefg\":\"hijklmn\"}",
  38. "true",
  39. 10,
  40. DeserializationError::Ok,
  41. "{\"abcdefg\":\"hijklmn\"}",
  42. JSON_OBJECT_SIZE(1) + 16
  43. },
  44. {
  45. "{\"hello\":\"world\"}",
  46. "{}",
  47. 10,
  48. DeserializationError::Ok,
  49. "{}",
  50. JSON_OBJECT_SIZE(0)
  51. },
  52. {
  53. // Input in an object, but filter wants an array
  54. "{\"hello\":\"world\"}",
  55. "[]",
  56. 10,
  57. DeserializationError::Ok,
  58. "null",
  59. 0
  60. },
  61. {
  62. // Member is a string, but filter wants an array
  63. "{\"example\":\"example\"}",
  64. "{\"example\":[true]}",
  65. 10,
  66. DeserializationError::Ok,
  67. "{\"example\":null}",
  68. JSON_OBJECT_SIZE(1) + 8
  69. },
  70. {
  71. // Member is a number, but filter wants an array
  72. "{\"example\":42}",
  73. "{\"example\":[true]}",
  74. 10,
  75. DeserializationError::Ok,
  76. "{\"example\":null}",
  77. JSON_OBJECT_SIZE(1) + 8
  78. },
  79. {
  80. // Input is an array, but filter wants an object
  81. "[\"hello\",\"world\"]",
  82. "{}",
  83. 10,
  84. DeserializationError::Ok,
  85. "null",
  86. 0
  87. },
  88. {
  89. // Input is a bool, but filter wants an object
  90. "true",
  91. "{}",
  92. 10,
  93. DeserializationError::Ok,
  94. "null",
  95. 0
  96. },
  97. {
  98. // Input is a string, but filter wants an object
  99. "\"hello\"",
  100. "{}",
  101. 10,
  102. DeserializationError::Ok,
  103. "null",
  104. 0
  105. },
  106. {
  107. // skip an integer
  108. "{\"an_integer\":666,example:42}",
  109. "{\"example\":true}",
  110. 10,
  111. DeserializationError::Ok,
  112. "{\"example\":42}",
  113. JSON_OBJECT_SIZE(1) + 8
  114. },
  115. {
  116. // skip a float
  117. "{\"a_float\":12.34e-6,example:42}",
  118. "{\"example\":true}",
  119. 10,
  120. DeserializationError::Ok,
  121. "{\"example\":42}",
  122. JSON_OBJECT_SIZE(1) + 8
  123. },
  124. {
  125. // skip false
  126. "{\"a_bool\":false,example:42}",
  127. "{\"example\":true}",
  128. 10,
  129. DeserializationError::Ok,
  130. "{\"example\":42}",
  131. JSON_OBJECT_SIZE(1) + 8
  132. },
  133. {
  134. // skip true
  135. "{\"a_bool\":true,example:42}",
  136. "{\"example\":true}",
  137. 10,
  138. DeserializationError::Ok,
  139. "{\"example\":42}",
  140. JSON_OBJECT_SIZE(1) + 8
  141. },
  142. {
  143. // skip null
  144. "{\"a_bool\":null,example:42}",
  145. "{\"example\":true}",
  146. 10,
  147. DeserializationError::Ok,
  148. "{\"example\":42}",
  149. JSON_OBJECT_SIZE(1) + 8
  150. },
  151. {
  152. // can skip a double-quoted string
  153. "{\"a_double_quoted_string\":\"hello\",example:42}",
  154. "{\"example\":true}",
  155. 10,
  156. DeserializationError::Ok,
  157. "{\"example\":42}",
  158. JSON_OBJECT_SIZE(1) + 8
  159. },
  160. {
  161. // can skip a single-quoted string
  162. "{\"a_single_quoted_string\":'hello',example:42}",
  163. "{\"example\":true}",
  164. 10,
  165. DeserializationError::Ok,
  166. "{\"example\":42}",
  167. JSON_OBJECT_SIZE(1) + 8
  168. },
  169. {
  170. // can skip an empty array
  171. "{\"an_empty_array\":[],example:42}",
  172. "{\"example\":true}",
  173. 10,
  174. DeserializationError::Ok,
  175. "{\"example\":42}",
  176. JSON_OBJECT_SIZE(1) + 8
  177. },
  178. {
  179. // can skip an empty array with spaces in it
  180. "{\"an_empty_array\":[\t],example:42}",
  181. "{\"example\":true}",
  182. 10,
  183. DeserializationError::Ok,
  184. "{\"example\":42}",
  185. JSON_OBJECT_SIZE(1) + 8
  186. },
  187. {
  188. // can skip an array
  189. "{\"an_array\":[1,2,3],example:42}",
  190. "{\"example\":true}",
  191. 10,
  192. DeserializationError::Ok,
  193. "{\"example\":42}",
  194. JSON_OBJECT_SIZE(1) + 8
  195. },
  196. {
  197. // can skip an array with spaces in it
  198. "{\"an_array\": [ 1 , 2 , 3 ] ,example:42}",
  199. "{\"example\":true}",
  200. 10,
  201. DeserializationError::Ok,
  202. "{\"example\":42}",
  203. JSON_OBJECT_SIZE(1) + 8
  204. },
  205. {
  206. // can skip an empty object
  207. "{\"an_empty_object\":{},example:42}",
  208. "{\"example\":true}",
  209. 10,
  210. DeserializationError::Ok,
  211. "{\"example\":42}",
  212. JSON_OBJECT_SIZE(1) + 8
  213. },
  214. {
  215. // can skip an empty object with spaces in it
  216. "{\"an_empty_object\":{ },example:42}",
  217. "{\"example\":true}",
  218. 10,
  219. DeserializationError::Ok,
  220. "{\"example\":42}",
  221. JSON_OBJECT_SIZE(1) + 8
  222. },
  223. {
  224. // can skip an object
  225. "{\"an_object\":{a:1,'b':2,\"c\":3},example:42}",
  226. "{\"example\":true}",
  227. 10,
  228. DeserializationError::Ok,
  229. "{\"example\":42}",
  230. JSON_OBJECT_SIZE(1) + 8
  231. },
  232. {
  233. // skip an object with spaces in it
  234. "{\"an_object\" : { a : 1 , 'b' : 2 , \"c\" : 3 } ,example:42}",
  235. "{\"example\":true}",
  236. 10,
  237. DeserializationError::Ok,
  238. "{\"example\":42}",
  239. JSON_OBJECT_SIZE(1) + 8
  240. },
  241. {
  242. "{\"an_integer\": 0,\"example\":{\"type\":\"int\",\"outcome\":42}}",
  243. "{\"example\":{\"outcome\":true}}",
  244. 10,
  245. DeserializationError::Ok,
  246. "{\"example\":{\"outcome\":42}}",
  247. 2 * JSON_OBJECT_SIZE(1) + 16
  248. },
  249. {
  250. // wildcard
  251. "{\"example\":{\"type\":\"int\",\"outcome\":42}}",
  252. "{\"*\":{\"outcome\":true}}",
  253. 10,
  254. DeserializationError::Ok,
  255. "{\"example\":{\"outcome\":42}}",
  256. 2 * JSON_OBJECT_SIZE(1) + 16
  257. },
  258. {
  259. // exclusion filter (issue #1628)
  260. "{\"example\":1,\"ignored\":2}",
  261. "{\"*\":true,\"ignored\":false}",
  262. 10,
  263. DeserializationError::Ok,
  264. "{\"example\":1}",
  265. JSON_OBJECT_SIZE(1) + 8
  266. },
  267. {
  268. // only the first element of array counts
  269. "[1,2,3]",
  270. "[true, false]",
  271. 10,
  272. DeserializationError::Ok,
  273. "[1,2,3]",
  274. JSON_ARRAY_SIZE(3)
  275. },
  276. {
  277. // only the first element of array counts
  278. "[1,2,3]",
  279. "[false, true]",
  280. 10,
  281. DeserializationError::Ok,
  282. "[]",
  283. JSON_ARRAY_SIZE(0)
  284. },
  285. {
  286. // filter members of object in array
  287. "[{\"example\":1,\"ignore\":2},{\"example\":3,\"ignore\":4}]",
  288. "[{\"example\":true}]",
  289. 10,
  290. DeserializationError::Ok,
  291. "[{\"example\":1},{\"example\":3}]",
  292. JSON_ARRAY_SIZE(2) + 2 * JSON_OBJECT_SIZE(1) + 8
  293. },
  294. {
  295. "[',2,3]",
  296. "[false,true]",
  297. 10,
  298. DeserializationError::IncompleteInput,
  299. "[]",
  300. JSON_ARRAY_SIZE(0)
  301. },
  302. {
  303. "[\",2,3]",
  304. "[false,true]",
  305. 10,
  306. DeserializationError::IncompleteInput,
  307. "[]",
  308. JSON_ARRAY_SIZE(0)
  309. },
  310. {
  311. // detect errors in skipped value
  312. "[!,2,\\]",
  313. "[false]",
  314. 10,
  315. DeserializationError::InvalidInput,
  316. "[]",
  317. JSON_ARRAY_SIZE(0)
  318. },
  319. {
  320. // detect incomplete string event if it's skipped
  321. "\"ABC",
  322. "false",
  323. 10,
  324. DeserializationError::IncompleteInput,
  325. "null",
  326. 0
  327. },
  328. {
  329. // detect incomplete string event if it's skipped
  330. "'ABC",
  331. "false",
  332. 10,
  333. DeserializationError::IncompleteInput,
  334. "null",
  335. 0
  336. },
  337. {
  338. // handle escaped quotes
  339. "'A\\'BC'",
  340. "false",
  341. 10,
  342. DeserializationError::Ok,
  343. "null",
  344. 0
  345. },
  346. {
  347. // handle escaped quotes
  348. "\"A\\\"BC\"",
  349. "false",
  350. 10,
  351. DeserializationError::Ok,
  352. "null",
  353. 0
  354. },
  355. {
  356. // detect incomplete string in presence of escaped quotes
  357. "'A\\'BC",
  358. "false",
  359. 10,
  360. DeserializationError::IncompleteInput,
  361. "null",
  362. 0
  363. },
  364. {
  365. // detect incomplete string in presence of escaped quotes
  366. "\"A\\\"BC",
  367. "false",
  368. 10,
  369. DeserializationError::IncompleteInput,
  370. "null",
  371. 0
  372. },
  373. {
  374. // skip empty array
  375. "[]",
  376. "false",
  377. 10,
  378. DeserializationError::Ok,
  379. "null",
  380. 0
  381. },
  382. {
  383. // skip empty array with spaces
  384. " [ ] ",
  385. "false",
  386. 10,
  387. DeserializationError::Ok,
  388. "null",
  389. 0
  390. },
  391. {
  392. // bubble up element error even if array is skipped
  393. "[1,'2,3]",
  394. "false",
  395. 10,
  396. DeserializationError::IncompleteInput,
  397. "null",
  398. 0
  399. },
  400. {
  401. // bubble up member error even if object is skipped
  402. "{'hello':'worl}",
  403. "false",
  404. 10,
  405. DeserializationError::IncompleteInput,
  406. "null",
  407. 0
  408. },
  409. {
  410. // bubble up colon error even if object is skipped
  411. "{'hello','world'}",
  412. "false",
  413. 10,
  414. DeserializationError::InvalidInput,
  415. "null",
  416. 0
  417. },
  418. {
  419. // bubble up key error even if object is skipped
  420. "{'hello:1}",
  421. "false",
  422. 10,
  423. DeserializationError::IncompleteInput,
  424. "null",
  425. 0
  426. },
  427. {
  428. // detect invalid value in skipped object
  429. "{'hello':!}",
  430. "false",
  431. 10,
  432. DeserializationError::InvalidInput,
  433. "null",
  434. 0
  435. },
  436. {
  437. // ignore invalid value in skipped object
  438. "{'hello':\\}",
  439. "false",
  440. 10,
  441. DeserializationError::InvalidInput,
  442. "null",
  443. 0
  444. },
  445. {
  446. // check nesting limit even for ignored objects
  447. "{}",
  448. "false",
  449. 0,
  450. DeserializationError::TooDeep,
  451. "null",
  452. 0
  453. },
  454. {
  455. // check nesting limit even for ignored objects
  456. "{'hello':{}}",
  457. "false",
  458. 1,
  459. DeserializationError::TooDeep,
  460. "null",
  461. 0
  462. },
  463. {
  464. // check nesting limit even for ignored values in objects
  465. "{'hello':{}}",
  466. "{}",
  467. 1,
  468. DeserializationError::TooDeep,
  469. "{}",
  470. JSON_OBJECT_SIZE(0)
  471. },
  472. {
  473. // check nesting limit even for ignored arrays
  474. "[]",
  475. "false",
  476. 0,
  477. DeserializationError::TooDeep,
  478. "null",
  479. 0
  480. },
  481. {
  482. // check nesting limit even for ignored arrays
  483. "[[]]",
  484. "false",
  485. 1,
  486. DeserializationError::TooDeep,
  487. "null",
  488. 0
  489. },
  490. {
  491. // check nesting limit even for ignored values in arrays
  492. "[[]]",
  493. "[]",
  494. 1,
  495. DeserializationError::TooDeep,
  496. "[]",
  497. JSON_ARRAY_SIZE(0)
  498. },
  499. {
  500. // supports back-slash at the end of skipped string
  501. "\"hell\\",
  502. "false",
  503. 1,
  504. DeserializationError::IncompleteInput,
  505. "null",
  506. 0
  507. },
  508. {
  509. // invalid comment at after an element in a skipped array
  510. "[1/]",
  511. "false",
  512. 10,
  513. DeserializationError::InvalidInput,
  514. "null",
  515. 0
  516. },
  517. {
  518. // incomplete comment at after an element in a skipped array
  519. "[1/*]",
  520. "false",
  521. 10,
  522. DeserializationError::IncompleteInput,
  523. "null",
  524. 0
  525. },
  526. {
  527. // missing comma in a skipped array
  528. "[1 2]",
  529. "false",
  530. 10,
  531. DeserializationError::InvalidInput,
  532. "null",
  533. 0
  534. },
  535. {
  536. // invalid comment at the beginning of array
  537. "[/1]",
  538. "[false]",
  539. 10,
  540. DeserializationError::InvalidInput,
  541. "[]",
  542. JSON_ARRAY_SIZE(0)
  543. },
  544. {
  545. // incomplete comment at the begining of an array
  546. "[/*]",
  547. "[false]",
  548. 10,
  549. DeserializationError::IncompleteInput,
  550. "[]",
  551. JSON_ARRAY_SIZE(0)
  552. },
  553. {
  554. // invalid comment before key
  555. "{/1:2}",
  556. "{}",
  557. 10,
  558. DeserializationError::InvalidInput,
  559. "{}",
  560. JSON_OBJECT_SIZE(0)
  561. },
  562. {
  563. // incomplete comment before key
  564. "{/*:2}",
  565. "{}",
  566. 10,
  567. DeserializationError::IncompleteInput,
  568. "{}",
  569. JSON_OBJECT_SIZE(0)
  570. },
  571. {
  572. // invalid comment after key
  573. "{\"example\"/1:2}",
  574. "{}",
  575. 10,
  576. DeserializationError::InvalidInput,
  577. "{}",
  578. JSON_OBJECT_SIZE(0)
  579. },
  580. {
  581. // incomplete comment after key
  582. "{\"example\"/*:2}",
  583. "{}",
  584. 10,
  585. DeserializationError::IncompleteInput,
  586. "{}",
  587. JSON_OBJECT_SIZE(0)
  588. },
  589. {
  590. // invalid comment after colon
  591. "{\"example\":/12}",
  592. "{}",
  593. 10,
  594. DeserializationError::InvalidInput,
  595. "{}",
  596. JSON_OBJECT_SIZE(0)
  597. },
  598. {
  599. // incomplete comment after colon
  600. "{\"example\":/*2}",
  601. "{}",
  602. 10,
  603. DeserializationError::IncompleteInput,
  604. "{}",
  605. JSON_OBJECT_SIZE(0)
  606. },
  607. {
  608. // comment next to an integer
  609. "{\"ignore\":1//,\"example\":2\n}",
  610. "{\"example\":true}",
  611. 10,
  612. DeserializationError::Ok,
  613. "{}",
  614. JSON_OBJECT_SIZE(0)
  615. },
  616. {
  617. // invalid comment after opening brace of a skipped object
  618. "{/1:2}",
  619. "false",
  620. 10,
  621. DeserializationError::InvalidInput,
  622. "null",
  623. 0
  624. },
  625. {
  626. // incomplete after opening brace of a skipped object
  627. "{/*:2}",
  628. "false",
  629. 10,
  630. DeserializationError::IncompleteInput,
  631. "null",
  632. 0
  633. },
  634. {
  635. // invalid comment after key of a skipped object
  636. "{\"example\"/:2}",
  637. "false",
  638. 10,
  639. DeserializationError::InvalidInput,
  640. "null",
  641. 0
  642. },
  643. {
  644. // incomplete comment after key of a skipped object
  645. "{\"example\"/*:2}",
  646. "false",
  647. 10,
  648. DeserializationError::IncompleteInput,
  649. "null",
  650. 0
  651. },
  652. {
  653. // invalid comment after value in a skipped object
  654. "{\"example\":2/}",
  655. "false",
  656. 10,
  657. DeserializationError::InvalidInput,
  658. "null",
  659. 0
  660. },
  661. {
  662. // incomplete comment after value of a skipped object
  663. "{\"example\":2/*}",
  664. "false",
  665. 10,
  666. DeserializationError::IncompleteInput,
  667. "null",
  668. 0
  669. },
  670. {
  671. // incomplete comment after comma in skipped object
  672. "{\"example\":2,/*}",
  673. "false",
  674. 10,
  675. DeserializationError::IncompleteInput,
  676. "null",
  677. 0
  678. },
  679. }; // clang-format on
  680. for (size_t i = 0; i < sizeof(testCases) / sizeof(testCases[0]); i++) {
  681. CAPTURE(i);
  682. DynamicJsonDocument filter(256);
  683. DynamicJsonDocument doc(256);
  684. TestCase& tc = testCases[i];
  685. CAPTURE(tc.filter);
  686. REQUIRE(deserializeJson(filter, tc.filter) == DeserializationError::Ok);
  687. CAPTURE(tc.input);
  688. CAPTURE(tc.nestingLimit);
  689. CHECK(deserializeJson(doc, tc.input, DeserializationOption::Filter(filter),
  690. DeserializationOption::NestingLimit(
  691. tc.nestingLimit)) == tc.error);
  692. CHECK(doc.as<std::string>() == tc.output);
  693. CHECK(doc.memoryUsage() == tc.memoryUsage);
  694. }
  695. }
  696. TEST_CASE("Zero-copy mode") { // issue #1697
  697. char input[] = "{\"include\":42,\"exclude\":666}";
  698. StaticJsonDocument<256> filter;
  699. filter["include"] = true;
  700. StaticJsonDocument<256> doc;
  701. DeserializationError err =
  702. deserializeJson(doc, input, DeserializationOption::Filter(filter));
  703. REQUIRE(err == DeserializationError::Ok);
  704. CHECK(doc.as<std::string>() == "{\"include\":42}");
  705. }
  706. TEST_CASE("Overloads") {
  707. StaticJsonDocument<256> doc;
  708. StaticJsonDocument<256> filter;
  709. using namespace DeserializationOption;
  710. // deserializeJson(..., Filter)
  711. SECTION("const char*, Filter") {
  712. deserializeJson(doc, "{}", Filter(filter));
  713. }
  714. SECTION("const char*, size_t, Filter") {
  715. deserializeJson(doc, "{}", 2, Filter(filter));
  716. }
  717. SECTION("const std::string&, Filter") {
  718. deserializeJson(doc, std::string("{}"), Filter(filter));
  719. }
  720. SECTION("std::istream&, Filter") {
  721. std::stringstream s("{}");
  722. deserializeJson(doc, s, Filter(filter));
  723. }
  724. #ifdef HAS_VARIABLE_LENGTH_ARRAY
  725. SECTION("char[n], Filter") {
  726. size_t i = 4;
  727. char vla[i];
  728. strcpy(vla, "{}");
  729. deserializeJson(doc, vla, Filter(filter));
  730. }
  731. #endif
  732. // deserializeJson(..., Filter, NestingLimit)
  733. SECTION("const char*, Filter, NestingLimit") {
  734. deserializeJson(doc, "{}", Filter(filter), NestingLimit(5));
  735. }
  736. SECTION("const char*, size_t, Filter, NestingLimit") {
  737. deserializeJson(doc, "{}", 2, Filter(filter), NestingLimit(5));
  738. }
  739. SECTION("const std::string&, Filter, NestingLimit") {
  740. deserializeJson(doc, std::string("{}"), Filter(filter), NestingLimit(5));
  741. }
  742. SECTION("std::istream&, Filter, NestingLimit") {
  743. std::stringstream s("{}");
  744. deserializeJson(doc, s, Filter(filter), NestingLimit(5));
  745. }
  746. #ifdef HAS_VARIABLE_LENGTH_ARRAY
  747. SECTION("char[n], Filter, NestingLimit") {
  748. size_t i = 4;
  749. char vla[i];
  750. strcpy(vla, "{}");
  751. deserializeJson(doc, vla, Filter(filter), NestingLimit(5));
  752. }
  753. #endif
  754. // deserializeJson(..., NestingLimit, Filter)
  755. SECTION("const char*, NestingLimit, Filter") {
  756. deserializeJson(doc, "{}", NestingLimit(5), Filter(filter));
  757. }
  758. SECTION("const char*, size_t, NestingLimit, Filter") {
  759. deserializeJson(doc, "{}", 2, NestingLimit(5), Filter(filter));
  760. }
  761. SECTION("const std::string&, NestingLimit, Filter") {
  762. deserializeJson(doc, std::string("{}"), NestingLimit(5), Filter(filter));
  763. }
  764. SECTION("std::istream&, NestingLimit, Filter") {
  765. std::stringstream s("{}");
  766. deserializeJson(doc, s, NestingLimit(5), Filter(filter));
  767. }
  768. #ifdef HAS_VARIABLE_LENGTH_ARRAY
  769. SECTION("char[n], NestingLimit, Filter") {
  770. size_t i = 4;
  771. char vla[i];
  772. strcpy(vla, "{}");
  773. deserializeJson(doc, vla, NestingLimit(5), Filter(filter));
  774. }
  775. #endif
  776. }