Hi,
I can see it is possible to parse JSON file with a QAction, something I need to do to interprete some HTTP request. So, in all example I saw on the Dojo, in QAction we have to add the Json library, for instance like that:
using Newtonsoft.Json;
But if I do on my system in DIS, I got an error saying it couldn't find that library name. So, Isn't part of the standard library in C#?
Hi Dominique,
Newtonsoft.Json is the most common way to parse to and from JSON messages, but it is still a custom library made by Newtonsoft and not part of your project by default.
If you are writing a connector that uses projects for QActions, then include the NuGet: NuGet Gallery | Newtonsoft.Json 13.0.3
If you are writing a connector that has the QAction code directly in the XML, add a dllImport reference to Newtonsoft.Json.dll
Because we use Newtonsoft in our core processes as well, this dll is part of the \Files folder. If you want to force a specific version of the dll with the second method, create a folder inside of the \ProtocolScripts folder and reference it as such. For example: dllOverride\Newtonsoft.Json.dll . This will force the QAction compilation to happen against this specific dll, and because it is signed, SLScripting will look for this exact version rather than the one found in \Files.
Hi Dominique,
You need to add a Newtonsoft nuget package to your QAction project.
Hi Dominique
Visual Studio 2019 is still fine. Could you have a look at which package sources are enabled? Probably the default one for nuget.org is not there: https://community.dataminer.services/question/nuget-package-references-not-installed/
Hi Dominique
Depending on your DataMiner version (10.0.10 +), you can just add the Newtonsoft.Json NuGet package to the QAction that needs it. When publishing with DIS, it will upload the protocol with the necessary DLLs that are extracted from the NuGet packages.
We often use custom DLL's and download the version we need to use and store it in the ProtocolScripts Folder of the DMA you are using and ensure we are referencing it in the XML.
We normally add in some C# exception handling within the StartUp QAction to let us know if any of the DLLs we are expecting are not already on the DMA in the ProtocolScripts folder. This can be really useful if you have to move your elements to a new DMA or reuse the driver in another DMS. Depending on the type of driver this would either be raised into the logs or as an alarmable parameter.
Hi Jorge,
Ihave tried to search for the Newtonsoft.Json packet but the nuget package manager list is empty and it is not finding the packet.
For info, I use DIS2019 and I tried to download with donet:
dotnet add package Newtonsoft.Json –version 13.0.3
But is not working because our donet version is 2.1.5 and that method only works with donet version higher than 2.12. But, if I want to upgrade donet to the latest version, it is said it will only work with DIS 2022 …