`jetson.stats` is not a valid JSON string
sheldonmaschmeyer opened this issue · comments
Describe the bug
The jetson.stats
is almost a valid JSON string but I need to make tweaks to the string for it to pass validation.
The following is done in JavaScript.
jetsonStats = jetsonStats.replace(/'/g, '"');
jetsonStats = jetsonStats.replace(/: datetime/g, ': "datetime');
jetsonStats = jetsonStats.replace(/\),/g, ')",');
JSON.parse(jetsonStats) // Success
To Reproduce
Steps to reproduce the behavior:
jetson = jtop()
jetson.start()
print(jetson.stats)
jetson.close()
-
Copy string to an online validator such as https://jsonlint.com/
Notice it does not pass. -
Pass string to Node.JS
jetsonStats = jetsonStats.replace(/'/g, '"');
jetsonStats = jetsonStats.replace(/: datetime/g, ': "datetime');
jetsonStats = jetsonStats.replace(/\),/g, ')",');
console.debug(jetsonStats)
JSON.parse(jetsonStats)
- Notice it now passes the online validator https://jsonlint.com/
Board
Ubuntu 18.04
jetson-stats==4.1.5
There is now a new function
jetson.json()
https://rnext.it/jetson_stats/reference/jtop.html#jtop.jtop.json