We are upgrading a legacy spreadsheet application to run in Excel 365 64 bit, win 10. The spreadsheet application interacts with a RESTful API through HTTP post, the response JSON is parsed leveraging "MSScriptControl.ScriptControl".
The spreadsheet application does not run in Excel 365 64 bit because the underlying "microsoft scripting runtime" (scrrun.dll) is a 32 bit file and is not supported natively in Excel 365, win 10. We have looked at various solutions like https://github.com/VBA-tools/VBA-JSON however this solution still makes use of the scripting runtime and fails. We considered also looking at alternative scripting runtimes such as https://github.com/tablacus/TablacusScriptControl but we would not be able to release the new scripting runtime on client machines.
The code below illustrates what we are currently doing in our VBA code:
Set request = CreateObject("MSXML2.XMLHTTP")
Set scriptControl = CreateObject("MSScriptControl.ScriptControl")
request.Open "post", custom_url, False
jsonRequest = "..."
request.Send (jsonRequest)
If request.Status = 200 Then
scriptControl.Language = "JScript"
scriptControl.AddCode "function GetPropertyValue(jsonObj, propertyName) { return jsonObj[propertyName]; } "
Set json = scriptControl.Eval("(" + request.ResponseText + ")")
End If
We have searched for a simple solution online but we cannot find one. How do you parse JSON in Excel 365 VBA without having to write a custom JSON parser? Are there any MS equivalent libraries to MSScript control that can be used in Excel 365 64 bit?