Json enconding and decoding for Matlab classes
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Adrián Lascurain
le 7 Juin 2023
Modifié(e) : Adrián Lascurain
le 14 Juin 2023
Hello , I'm currently defining a new class and I would like to encrypt (using AES) my object and all the information it contains, for this I used the jsonencode Matlab instruction for creating a character vector that is able to be encrypted, this already worked but when I decrypt the object and try to reconstruct it as my original object using Jsondecode it becomes an structure and not the class type that was defined.
So I would like to know if is there someway (method or instruction) to decode this into my original class type or shall I reconstruct the object using the data contained in the structure?
Thanks in advanced.
0 commentaires
Réponse acceptée
Lakshay Rose
le 14 Juin 2023
Modifié(e) : Lakshay Rose
le 14 Juin 2023
Hi Adrián Lascurain,
As per my understanding you are trying to encode an object using “jsonencode” and then decode it using “jsondecode” and are getting the return output as a structure.
“jsonencode” function in MATLAB comes with the limitation that when objects are encoded, they don’t preserve their original structure.
To solve this problem there is a workaround of creating your own function which converts your decoded structure back to the object of your desired class.
You can refer to the below documentation to learn more about usage and limitations of “jsonencode” and “jsondecode” functions in MATLAB –
1 commentaire
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!