TCP/IP or serial port data is JSON : process it to C++ structure: and use that info # QT QML C++
-
Hi
I have a scenario where I get data from a serial or TCPIP port in Json.
I need to first of all check if the JSON string exist and then convert it into C++ structure and further use the info to process information to plot , display info on GUI extra.I used to do the whole process in Matlab and now I have to do it in QT QML.
Right now I am able to:
1.) Connect to serial or TCP port and send cmd to receive data.
2.) I want to now check if JSON string is present in the data received and convert it into C++ structure.
3.) Basically I will use the info from this structure to to display it on the QML GUI, or may be use the data points and plot them on the graph.could any one help me how to go about point 2 and 3. Any small existing example would be great.
Regards
Prasad -
Hi,
Since you are sing QtQuick, why not handle the JSON directly in the javascript portion of your code ?
-
Hi,
Since you are sing QtQuick, why not handle the JSON directly in the javascript portion of your code ?
@SGaist hi any example on how to do that. Or could you put some light on it with some few sentences I would try to figure it out myself.
-
@SGaist hi any example on how to do that. Or could you put some light on it with some few sentences I would try to figure it out myself.
Have you already read https://doc.qt.io/qt-5.11/qtqml-cppintegration-overview.html ?
And I agree with @SGaist, JSON is JavaScript Object Notation, so you should easily be able to handle JSON on the JavaScript side. For documentation on how to do that, use Google :)