I am trying to convert a JSON string to XML string in my excel macro, and I found out that Newtonsoft's json .net library has a DeserializeXmlNode
method in JsonConvert (https://www.newtonsoft.com/json/help/html/convertingjsonandxml.htm) which I think would help me convert a JSON string to XML string - but I am not sure if I can use this library in MS Excel...
Again, I have a JSON string in a VBA variable, and I want to convert it into an XML string using DeserializeXmlNode method, and get the XML Data returned into another VBA variable and MsgBox the converted XML. Is this possible? How do I use the Newtonsoft JSON .NET library in my excel workbook? I am new to vba and I am unsure regarding this... Kindly advice... Thanks!
P.S. I read this topic How to use Newtonsoft library with an excel macro and in comments Tim says create a com dll - if that's going to help me, how do I do that?
Edit 2 : Here's how the updated JSON string with array looks like - (again this is a representation of my updated JSON, actually its very big)
{
"metadata": {
"refYear": 2022,
"formName": "F3CB-3CD"
},
"data": {
"FORM3CB": {
"F3CB": {
"Declaration": {
"Point1": {
"My_Our1": "Our",
"Observations": [
{
"ObservationsCode": "01",
"ObservationsVal": "Observation 1 "
},
{
"ObservationsCode": "02",
"ObservationsVal": "Observation 2"
},
{
"ObservationsCode": "03",
"ObservationsVal": "Observation 3"
}
]
}
},
"PartA": {
"AssesseeName": {
"Name": "Sample Name"
}
}
}
}
}
}