Create JSON object as C-API
15 views (last 30 days)
Show older comments
Hi all,
I'm programming a dSpace vehicle computer (MABX III) with a Simulink Model based on Matlab functions.
I need to pack some data into a JSON file to send it out over a Ethernet port. Matlab is giving for this the jdataencode() function that looks like following:
s.inverter.m_temp.Date = SystemDate;
s.inverter.m_temp.Value = m_temp;
s.inverter.inv_tmp.Date = SystemDate;
s.inverter.inv_tmp.Value = inv_tmp;
json = jdataencode(s);
Sadly, the jdataencode function is not supported for embedded C conversion which makes it unusable for my usecase. Does anyone know some kind of C-API to create a JSON object which is build able on embedded C computing? Thanks in advance!
0 Comments
Answers (1)
Githin George
on 9 Nov 2023
Hello,
My understanding is that you are trying to use the “jdataencoder” function from JSONLab and you are not able to generate code for this function. In fact, code generation functionality is not provided for the inbuilt MATLAB function “jsonencode” as well.
A possible workaround for the issue would be to use a “C Function” block in Simulink to convert your structure into a JSON string with the help of any custom code or C libraries. Please refer to the following MathWorks video link to learn more about using C Function block.
I hope this helps.
0 Comments
See Also
Categories
Find more on JSON Format in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!