rbonghi / jetson_stats

📊 Simple package for monitoring and control your NVIDIA Jetson [Orin, Xavier, Nano, TX] series

Home Page:https://rnext.it/jetson_stats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`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()
  1. Copy string to an online validator such as https://jsonlint.com/
    Notice it does not pass.

  2. 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)
  1. Notice it now passes the online validator https://jsonlint.com/

Board

Ubuntu 18.04
jetson-stats==4.1.5