Data Backup JSON Files Improperly Formatted
I'm trying to read the data backup files but am getting errors parsing the "timelog" data in tasks.json if someone used quotes in their comment and it's quite problematic.
Example timelog comment:
Worked on "thing"
JSON file shows:
"timelog": [
{
"author": "vSk2ZXxiICY9",
"dateCreated": "2022-04-25 12:00:00",
"hours": 0.5,
"trackComment": "Worked on "thing""
}
]
While the file extension is "json", this is not json data and it's proving very difficult to resolve with double quotes used both as key/value identifiers AND within comment strings.. The comment parenthesis should be switched to single quotes or simply removed.
Okay, I have some updates.. @... submitted a ticket and Vadim reached out after testing the data exporting.. It seems that the json file is in fact properly formatted - my mistake.
Quotations entered in comments are written as:
"timelog":[
{
"author":"ZCGB7Juf3qIz",
"dateCreated":"2023-06-16 11:25:53",
"hours":0.16666667,
"trackComment":"this is a test comment in timelogs \"test\""
}
]
Note the escape characters before the quotes inside the string. Correct for json format; however, Python has some nuances when reading these.
For those doing something similar and end up here, search "json.load misses escape before quotes in json file site:stackoverflow.com" and you'll find some discussions on how to follow some extra steps when reading the json file to get timelog as a properly formatted (per Python) list of dicts. Or check here, here, here.
Thanks a lot for sharing the solution with the Community Greg Collins 🤗
Lisa Community Team at Wrike Wrike Product Manager Conviértete en un experto en Wrike con Wrike Discover
Lisa Wrike Team member Conviértete en un experto en Wrike con Wrike Discover