thingsboard / dart_thingsboard_client

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

json data entry returns non-valid json #36

Closed fatihmerickoc closed 2 months ago

fatihmerickoc commented 5 months 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.

ybeshkarov commented 2 months ago

Hello @fatihmerickoc,

Thank you for your contribution! https://github.com/thingsboard/dart_thingsboard_client/pull/37