2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-31 09:20:52 +00:00
Commit Graph

48 Commits

Author SHA1 Message Date
m-holger
9e90007a4a Add new private class JSON::Writer
Create a simple utility class for writing JSON to a pipeline.
2024-02-16 10:32:41 +00:00
m-holger
a41b789995 Add new method JSON::getDictItem 2024-01-15 15:02:52 +00:00
Jay Berkenbilt
9db5d75b2b Update copyright to 2024 2024-01-01 10:56:06 -05:00
m-holger
acd0acf169 Fix doc typos 2023-06-02 19:24:12 +01:00
m-holger
698a70e6a8 Code tidy - reflow comments and strings 2023-05-27 10:54:19 +01:00
Jay Berkenbilt
60965d5f4d Rerun clang-format 2023-05-21 13:35:09 -04:00
Jay Berkenbilt
ef24a4151b Move JSON_array for C++-20 compatibility (fixes #943) 2023-05-20 18:25:58 -04:00
m-holger
e6577a1323 Replace 'virtual' specifier with 'override' 2023-05-20 15:41:56 +01:00
Jay Berkenbilt
c99a1ecd4f Update copyright to 2023 2023-02-25 14:18:13 -05:00
m-holger
7ae1e80fd6 Change JSON::Members::value to std::unique_ptr 2023-02-19 12:06:36 +00:00
m-holger
a4f3dddb79 Change JSON_dictionary and JSON_array to store JSON objects rather than std::shared_ptr<JSON_value>
Recognise that JSON objects are effectively shared pointers to JSON_value.
2023-02-19 12:05:53 +00:00
Jay Berkenbilt
e4e03e9ac1
Merge pull request #890 from m-holger/jpsp
Eliminate the use of shared pointers in JSONParser
2023-02-18 17:43:02 -05:00
m-holger
d80b63c3c0 Refactor JSON type checks 2023-02-11 15:44:03 -05:00
m-holger
b6f048546f Eliminate the use of shared pointers in JSONParser 2023-02-05 12:46:38 +00:00
m-holger
3dde66ddcd Refactor JSON::writeNext 2023-01-28 14:49:32 -05:00
Jay Berkenbilt
9a9a7ab097 Comment about qpdf/PointerHolder.hh in public headers 2022-09-23 15:15:39 -04:00
Jay Berkenbilt
0e3d4cdc97 Fix/clarify meaning of depth parameter to json write methods 2022-07-31 10:32:55 -04:00
Jay Berkenbilt
8ad39a6c9a Spell check 2022-07-31 10:32:55 -04:00
Jay Berkenbilt
4674c04cb8 JSON schema: support multi-element array validation 2022-07-24 16:44:51 -04:00
Jay Berkenbilt
f8d1ab9462 JSON schema -- accept single item in place of array
When the schema wants a variable-length array, allow a single item as
well as allowing an array.
2022-07-24 16:17:03 -04:00
m-holger
5c6808b484 Fix minor doc typos in JSON.hh 2022-06-09 06:40:18 -04:00
Jay Berkenbilt
c56a9ca7f6 JSON: Fix large file support 2022-05-21 09:43:45 -04:00
Jay Berkenbilt
3eb77a7004 JSON: detect duplicate dictionary keys while parsing 2022-05-20 10:13:15 -04:00
Jay Berkenbilt
4c7cfd5cbc JSON reactor: improve handling of nested containers
Call the parent container's item method before calling the child
item's start method so we can easily know the current nesting level
when nested items are added.
2022-05-14 17:35:06 -04:00
Jay Berkenbilt
16f4f94cd9 Prepare code for JSON v2
Update getJSON() methods and calls to them
2022-05-07 11:12:01 -04:00
Jay Berkenbilt
948de60990 Objects json: write incrementally and in numeric order
The following script was used to adjust test data:

----------
#!/usr/bin/env python3
import json
import sys
import re

def json_dumps(data):
    return json.dumps(data, ensure_ascii=False,
                      indent=2, separators=(',', ': '))

for filename in sys.argv[1:]:
    with open(filename, 'r') as f:
        data = json.loads(f.read())
    if 'objects' not in data:
        continue
    trailer = None
    to_sort = []
    for k, v in data['objects'].items():
        if k == 'trailer':
            trailer = v
        else:
            m = re.match(r'^(\d+) \d+ R', k)
            if m:
                to_sort.append([int(m.group(1)), k, v])
    newobjects = {x[1]: x[2] for x in sorted(to_sort)}
    if trailer is not None:
        newobjects['trailer'] = trailer
    data['objects'] = newobjects
print(json_dumps(data))
----------
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
1615d7feaf Make JSON::writeNext public 2022-05-07 08:26:31 -04:00
Jay Berkenbilt
0500d4347a JSON: add blob type that generates base64-encoded binary data 2022-05-06 19:14:52 -04:00
Jay Berkenbilt
05fda4afa2 Change JSON parser to parse from an InputSource 2022-05-04 12:07:11 -04:00
Jay Berkenbilt
e259635986 JSON: add write methods and implement unparse() in terms of those 2022-05-04 12:07:11 -04:00
Jay Berkenbilt
8d2a0eda5a Add reactors to the JSON parser 2022-05-01 19:55:52 -04:00
Jay Berkenbilt
cdd0b4fb7d Use = default and = delete where possible in classes 2022-04-16 11:39:14 -04:00
Jay Berkenbilt
a68703b07e Replace PointerHolder with std::shared_ptr in library sources only
(patrepl and cleanpatch are my own utilities)

patrepl s/PointerHolder/std::shared_ptr/g {include,libqpdf}/qpdf/*.hh
patrepl s/PointerHolder/std::shared_ptr/g libqpdf/*.cc
patrepl s/make_pointer_holder/std::make_shared/g libqpdf/*.cc
patrepl s/make_array_pointer_holder/QUtil::make_shared_array/g libqpdf/*.cc
patrepl s,qpdf/std::shared_ptr,qpdf/PointerHolder, **/*.cc **/*.hh
git restore include/qpdf/PointerHolder.hh
cleanpatch
./format-code
2022-04-09 17:33:29 -04:00
Jay Berkenbilt
12f1eb15ca Programmatically apply new formatting to code
Run this:

for i in  **/*.cc **/*.c **/*.h **/*.hh; do
  clang-format < $i >| $i.new && mv $i.new $i
done
2022-04-04 08:10:40 -04:00
Jay Berkenbilt
c62e8e2b28 Update for clean compile with POINTERHOLDER_TRANSITION=2 2022-02-07 17:38:22 -05:00
Jay Berkenbilt
cfaa2de804 Update copyright for 2022 2022-02-04 16:36:22 -05:00
Jay Berkenbilt
f0c2e0ef1e JSON: use std::shared_ptr internally 2022-02-04 13:12:37 -05:00
m-holger
e813176bc0 Fix some doc typos 2022-02-02 14:07:32 -06:00
Jay Berkenbilt
8dea480c9f Allow optional fields in json "schema" checks 2022-01-30 13:11:03 -05:00
Jay Berkenbilt
37105710ee Implement JSONHandler for recursively processing JSON 2022-01-30 13:11:03 -05:00
Jay Berkenbilt
e8e8f6f43c Add JSON::parse 2022-01-30 13:11:03 -05:00
Jay Berkenbilt
aa0a379b37 Add JSON::isDictionary and JSON::isArray 2022-01-30 13:11:03 -05:00
Jay Berkenbilt
bf8fd41fee Update copyright to 2021 2021-01-04 16:26:58 -05:00
Jay Berkenbilt
e5cc065598 Update copyright to 2020 2020-01-26 16:57:27 -05:00
Jay Berkenbilt
3472f6c984 Update copyrights for 2019 2019-01-07 07:54:55 -05:00
Jay Berkenbilt
2e342ee5bb Spell check 2019-01-04 21:33:14 -05:00
Jay Berkenbilt
3440ea7d3c JSON::serialize -> unparse
Unparse is admittedly strange, but I'd rather be strange and
consistent, and everything else in the qpdf library uses unparse to
serialize. (If you're reading this, the convention of using "unparse"
comes from the "clu" programming language.)
2018-12-25 11:52:21 -05:00
Jay Berkenbilt
651179b5da Add simple JSON serializer 2018-12-21 18:34:56 -05:00