How to create JSON-Code
Afficher commentaires plus anciens
Hi,
Can someone help me how I create the attached JSON-Code? I know I have to do it with a struct, but don't know how to do it exactly with the brackets.
{
"query": "Who likes Pizza?",
"documents": [
{
"text": "Andreas likes Pizza."
},
{
"docx": "b64;base64EncodededWordDocument"
}
]
}
Réponses (1)
the cyclist
le 7 Avr 2023
0 votes
If not, can you be more specific about what you have as input, and what exactly you want for output?
3 commentaires
Christopher Dirks
le 7 Avr 2023
Modifié(e) : Christopher Dirks
le 7 Avr 2023
I don't know if this is exactly what you need, but I think it should give you an idea of how to create a nested structure, and then convert it to JSON:
s(1).Query = 'View from the 15th Floor';
s(1).Documents.text = "Andreas";
s(1).Documents.docx = "b64;base64";
s(2).Query = 'View from the 31st Floor';
s(2).Documents.text = "Joe";
s(2).Documents.docx = "b32;base32";
j = jsonencode(s,PrettyPrint=true)
Christopher Dirks
le 9 Avr 2023
Catégories
En savoir plus sur JSON Format dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!