Hi All, I am trying to process an API response and put it into a table, so far so good, until I got to a string array as below:
"filters": [
"1260-1bwkvpznu2e4i1j5roxqbdu0qp"
],
I am declaring it as a string[] but when i come to try process that into a table entry, it just doesn't seem to work and the field in the table is empty.
What is the best way of processing this as i need to use it when sending specific PUT requests?
Hi Ryan,
It looks like you're working with a JSON response. Are you using a JSON parser/serializer like Newtonsoft.Json to handle the deserialization?
Here’s a simple example using Newtonsoft.Json within a QAction, where the JSON string is read from a protocol parameter:
using Newtonsoft.Json;
[Serializable] public class FiltersResponse
using System;
{
public string[] filters { get; set; }
}public class QAction
{
public static void Run(SLProtocol protocol)
{
// Get the JSON string from protocol parameter with PID 1
string json = (string)protocol.GetParameter(1);if (string.IsNullOrWhiteSpace(json))
return;// Deserialize the JSON into a strongly-typed object
FiltersResponse response = JsonConvert.DeserializeObject<FiltersResponse>(json);// Now 'response.filters' contains the array of filter strings
}
}
Feel free to share a snippet of your code in case this was not what you were looking for.