thingsboard / dart_thingsboard_client

ThingsBoard API client library for Dart developers.
BSD 3-Clause "New" or "Revised" License
59 stars 30 forks source link

json data entry returns non-valid json #36

Open fatihmerickoc opened 1 month ago

fatihmerickoc commented 1 month ago

in my Thingsboard account, i have a json value in the server attributes and a problem occurs every time i try fetch it. it returns me a JsonDataEntry which contains the value as a string, that is incorrect because when you return it as a String, it removes the quotes from the JSON value, which then makes it impossible to work with it.

ex of my value in Thingsboard:

{
  "people": [
    {
      "name": "Alice",
      "age": 30,
      "hobbies": ["reading", "photography"]
    },
    {
      "name": "Bob",
      "age": 25,
      "hobbies": ["music", "running"]
    },
    {
      "name": "Charlie",
      "age": 35,
      "hobbies": ["painting", "gardening"]
    }
  ]
}

what i get in return:

  people: [
    {
      name: Alice,
      age: 30,
      hobbies: [reading, photography]
    },
    {
     name: Bob,
     age: 25,
      hobbies: [music, running]
    },
    {
      name: Charlie,
      age: 35,
      hobbies: [painting, gardening]
    }
  ]
}

this happens because in the lib/src/model/telemetry_models.dart in the line 352 the method _parseValue, it converts my JSON value to map then to String via the .toString() method which then removes all the quotes.