3
3
4
4
parser = JSONParser ()
5
5
6
- incomplete_json = '{"name": "John", "age": 18, "family":'
6
+ incomplete_json = """
7
+
8
+ {"web-app":
9
+ {"servlet": [
10
+ {
11
+ "servlet-name3": "xyz",
12
+ "servlet-name4": null,
13
+
14
+ "servlet-name2": true,
15
+ "servlet-name1": false,
16
+ "servlet-class": "org.cofax.cds.CDSServlet",
17
+ "init-param": {
18
+
19
+
20
+ "configGlossary:installationAt": "Philadelphia, PA",
21
+
22
+ "configGlossary:adminEmail": "[email protected] ",
23
+
24
+ "configGlossary:poweredBy": "Cofax",
25
+ "configGlossary:poweredByIcon": "/images/cofax.gif",
26
+ "configGlossary:staticPath": "/content/static",
27
+ "templateProcessorClass": "org.cofax.WysiwygTemplate",
28
+ "templateLoaderClass": "org.cofax.FilesTemplateLoader",
29
+ "templatePath": "templates",
30
+ "templateOverridePath": "",
31
+ "defaultListTemplate": "listTemplate.htm",
32
+ "defaultFileTemplate": "articleTemplate.htm",
33
+ "useJSP": false,
34
+ "jspListTemplate": "listTemplate.jsp",
35
+ "jspFileTemplate": "articleTemplate.jsp",
36
+ "cachePackageTagsTrack": 200,
37
+ "cachePackageTagsStore": 200,
38
+ "cachePackageTagsRefresh": 60,
39
+ "cacheTemplatesTrack": 100,
40
+ "cacheTemplatesStore": 50,
41
+ "cacheTemplatesRefresh": 15,
42
+ "cachePagesTrack": 200,
43
+ "cachePagesStore": 100,
44
+ "cachePagesRefresh": 10,
45
+ "cachePagesDirtyRead": 10,
46
+ "searchEngineListTemplate": "forSearchEnginesList.htm",
47
+ "searchEngineFileTemplate": "forSearchEngines.htm",
48
+ "searchEngineRobotsDb": "WEB-INF/robots.db",
49
+ "useDataStore": true,
50
+ "dataStoreClass": "org.cofax.SqlDataStore",
51
+ "redirectionClass": "org.cofax.SqlRedirection",
52
+ "dataStoreName": "cofax",
53
+ "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
54
+ "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
55
+ "dataStoreUser": "sa",
56
+ "dataStorePassword": "dataStoreTestQuery",
57
+ "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
58
+ "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
59
+ "dataStoreInitConns": 10,
60
+ "dataStoreMaxConns": 100,
61
+ "dataStoreConnUsageLimit": 100,
62
+ "dataStoreLogLevel": "debug",
63
+ "maxUrlLength": 500}},
64
+ {
65
+ "servlet-name": "cofaxEmail",
66
+ "servlet-class": "org.cofax.cds.EmailServlet",
67
+ "init-param": {
68
+ "mailHost": "mail1",
69
+ "mailHostOverride": "mail2"}},
70
+ {
71
+ "servlet-name": "cofaxAdmin",
72
+ "servlet-class": "org.cofax.cds.AdminServlet"},
73
+
74
+ {
75
+ "servlet-name": "fileServlet",
76
+ "servlet-class": "org.cofax.cds.FileServlet"},
77
+ {
78
+ "servlet-name": "cofaxTools",
79
+ "servlet-class": "org.cofax.cms.CofaxToolsServlet",
80
+ "init-param": {
81
+ "templatePath": "toolstemplates/",
82
+ "log": 1,
83
+ "logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
84
+ "logMaxSize": "",
85
+ "dataLog": 1,
86
+ "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
87
+ "dataLogMaxSize": "",
88
+ "removePageCache": "/content/admin/remove?cache=pages&id=",
89
+ "removeTemplateCache": "/content/admin/remove?cache=templates&id=",
90
+ "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
91
+ "lookInContext": 1,
92
+ "adminGroupID": 4,
93
+ "betaServer": true}}],
94
+ "servlet-mapping": {
95
+ "cofaxCDS": "/",
96
+ "cofaxEmail": "/cofaxutil/aemail/*",
97
+ "cofaxAdmin": "/admin/*",
98
+ "fileServlet": "/static/*",
99
+ "cofaxTools": "/tools/*"},
100
+
101
+ "taglib": {
102
+ "taglib-uri": "cofax.tld",
103
+ "taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
104
+ """
105
+
7
106
8
107
json = ""
9
108
10
- for char in incomplete_json :
109
+ for char in incomplete_json . strip () :
11
110
json += char
12
111
print (f'\n Incomplete or streaming json:\n { json } ' )
13
112
print (f'Final and usable JSON without crashing:\n { parser .parse (json )} ' )
14
113
sys .stdout .flush ()
15
- time .sleep (0.3 )
114
+ time .sleep (0.01 )
0 commit comments