I’m dealing with a third party gateway and I’m trying to deserialize the response to a dictionary.
Here is a simplified example of what I’m getting back from that gateway.
I’m trying to figure out why the entries are null when using FromJson.
using System;
using ServiceStack;
using ServiceStack.Text;
namespace ServiceStackSupport
{
public class CountryResponse
{
public Dictionary<string, object> CountryList;
}
internal class Program
{
static void Main(string[] args)
{
string json = "[\n {\n \"active\": \"true\",\n \"country\": \"Brazil\",\n \"note\": \"A note about Brazil\",\n \"other1\": \"198765\",\n \"other2\": \"\",\n \"other3\": \"10\",\n \"other9\": \"\"\n },\n {\n \"active\": \"true\",\n \"country\": \"Algeria\",\n \"note\": \"A note about Alegria\",\n \"other4\": \"wtv\",\n \"other8\": \"\",\n \"other6\": \"-1\"\n },\n {\n \"active\": \"true\",\n \"country\": \"Cabodia\",\n \"note\": \"A note about Cabodia\",\n \"other3\": \"108\",\n \"other8\": \"\",\n \"other10\": \"-1\"\n }\n]";
JsConfig.Init(new Config {
TextCase = TextCase.SnakeCase,
PropertyConvention = PropertyConvention.Lenient
});
var obj = JSON.parse(json);
var entriesAreAllNull = json.FromJson<List<CountryResponse>>();
Console.WriteLine();
}
}
}