-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: true, false and null values in JSON
- Loading branch information
Showing
3 changed files
with
108 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,112 @@ | |
|
||
parser = JSONParser() | ||
|
||
incomplete_json = '{"name": "John", "age": 18, "family":' | ||
incomplete_json = """ | ||
{"web-app": | ||
{"servlet": [ | ||
{ | ||
"servlet-name3": "xyz", | ||
"servlet-name4": null, | ||
"servlet-name2": true, | ||
"servlet-name1": false, | ||
"servlet-class": "org.cofax.cds.CDSServlet", | ||
"init-param": { | ||
"configGlossary:installationAt": "Philadelphia, PA", | ||
"configGlossary:adminEmail": "[email protected]", | ||
"configGlossary:poweredBy": "Cofax", | ||
"configGlossary:poweredByIcon": "/images/cofax.gif", | ||
"configGlossary:staticPath": "/content/static", | ||
"templateProcessorClass": "org.cofax.WysiwygTemplate", | ||
"templateLoaderClass": "org.cofax.FilesTemplateLoader", | ||
"templatePath": "templates", | ||
"templateOverridePath": "", | ||
"defaultListTemplate": "listTemplate.htm", | ||
"defaultFileTemplate": "articleTemplate.htm", | ||
"useJSP": false, | ||
"jspListTemplate": "listTemplate.jsp", | ||
"jspFileTemplate": "articleTemplate.jsp", | ||
"cachePackageTagsTrack": 200, | ||
"cachePackageTagsStore": 200, | ||
"cachePackageTagsRefresh": 60, | ||
"cacheTemplatesTrack": 100, | ||
"cacheTemplatesStore": 50, | ||
"cacheTemplatesRefresh": 15, | ||
"cachePagesTrack": 200, | ||
"cachePagesStore": 100, | ||
"cachePagesRefresh": 10, | ||
"cachePagesDirtyRead": 10, | ||
"searchEngineListTemplate": "forSearchEnginesList.htm", | ||
"searchEngineFileTemplate": "forSearchEngines.htm", | ||
"searchEngineRobotsDb": "WEB-INF/robots.db", | ||
"useDataStore": true, | ||
"dataStoreClass": "org.cofax.SqlDataStore", | ||
"redirectionClass": "org.cofax.SqlRedirection", | ||
"dataStoreName": "cofax", | ||
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver", | ||
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon", | ||
"dataStoreUser": "sa", | ||
"dataStorePassword": "dataStoreTestQuery", | ||
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';", | ||
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log", | ||
"dataStoreInitConns": 10, | ||
"dataStoreMaxConns": 100, | ||
"dataStoreConnUsageLimit": 100, | ||
"dataStoreLogLevel": "debug", | ||
"maxUrlLength": 500}}, | ||
{ | ||
"servlet-name": "cofaxEmail", | ||
"servlet-class": "org.cofax.cds.EmailServlet", | ||
"init-param": { | ||
"mailHost": "mail1", | ||
"mailHostOverride": "mail2"}}, | ||
{ | ||
"servlet-name": "cofaxAdmin", | ||
"servlet-class": "org.cofax.cds.AdminServlet"}, | ||
{ | ||
"servlet-name": "fileServlet", | ||
"servlet-class": "org.cofax.cds.FileServlet"}, | ||
{ | ||
"servlet-name": "cofaxTools", | ||
"servlet-class": "org.cofax.cms.CofaxToolsServlet", | ||
"init-param": { | ||
"templatePath": "toolstemplates/", | ||
"log": 1, | ||
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log", | ||
"logMaxSize": "", | ||
"dataLog": 1, | ||
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log", | ||
"dataLogMaxSize": "", | ||
"removePageCache": "/content/admin/remove?cache=pages&id=", | ||
"removeTemplateCache": "/content/admin/remove?cache=templates&id=", | ||
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder", | ||
"lookInContext": 1, | ||
"adminGroupID": 4, | ||
"betaServer": true}}], | ||
"servlet-mapping": { | ||
"cofaxCDS": "/", | ||
"cofaxEmail": "/cofaxutil/aemail/*", | ||
"cofaxAdmin": "/admin/*", | ||
"fileServlet": "/static/*", | ||
"cofaxTools": "/tools/*"}, | ||
"taglib": { | ||
"taglib-uri": "cofax.tld", | ||
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}} | ||
""" | ||
|
||
|
||
json = "" | ||
|
||
for char in incomplete_json: | ||
for char in incomplete_json.strip(): | ||
json += char | ||
print(f'\nIncomplete or streaming json:\n{json}') | ||
print(f'Final and usable JSON without crashing:\n{parser.parse(json)}') | ||
sys.stdout.flush() | ||
time.sleep(0.3) | ||
time.sleep(0.01) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
""" | ||
torrentp. | ||
Partial Json. | ||
A great wrapped library for downloading from torrent. | ||
Parsing ChatGPT JSON stream response — Partial and incomplete JSON parser python library for OpenAI | ||
""" | ||
from .json_parser import JSONParser | ||
|
||
__version__ = "0.0.5" | ||
__version__ = "0.0.6" | ||
__author__ = 'Nima Akbarzadeh' | ||
__author_email__ = "[email protected]" | ||
__license__ = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters