I have a windows service, which loads parameters from database. There is a parameter is a Json string which has a field that is another Json string.
{
"dll_fullname": "ScheduledTask.DialogTechSync.DialogTechSyncTask",
"dll_para_json": "{"data_length": "5000", "max_parallelism": "4", "pause_time": "20"}"
}
In the above example, dll_para_json is the Json string in this Json string.
In the C# code, if I hardcode it as below, it works fine:
{ \"dll_fullname\": \"ScheduledTask.DialogTechSync.DialogTechSyncTask\",\"dll_para_json\": \"{\"data_length\": \"5000\", \"max_parallelism\": \"4\", \"pause_time\": \"20\"}\" }
However, if I put it in database, it has exception when I deserialize it:
dynamic results = JsonConvert.DeserializeObject<dynamic>(json);
I also tried to put it as below
{ \\"dll_fullname\\": \\"ScheduledTask.DialogTechSync.DialogTechSyncTask\\",\\"dll_para_json\\": \\"{\\"data_length\\": \\"5000\\", \\"max_parallelism\\": \\"4\\", \\"pause_time\\": \\"20\\"}\\" }
{ \\\"dll_fullname\\\": \\\"ScheduledTask.DialogTechSync.DialogTechSyncTask\\\",\\\"dll_para_json\\\": \\\"{\\\"data_length\\\": \\\"5000\\\", \\\"max_parallelism\\\": \\\"4\\\", \\\"pause_time\\\": \\\"20\\\"}\\\" }
{ \\\\"dll_fullname\\\\": \\\\"ScheduledTask.DialogTechSync.DialogTechSyncTask\\\\",\\\\"dll_para_json\\\\": \\\\"{\\\\"data_length\\\\": \\\\"5000\\\\", \\\\"max_parallelism\\\\": \\\\"4\\\\", \\\\"pause_time\\\\": \\\\"20\\\\"}\\\\" }
None worked. Always the same exception:
Error in parsing job: Newtonsoft.Json.JsonReaderException: After parsing a value an unexpected character was encountered: d. Path 'dll_para_json', line 1, position **.
at Newtonsoft.Json.JsonTextReader.ParsePostValue(Boolean ignoreComments)
at Newtonsoft.Json.JsonTextReader.Read()
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateJObject(JsonReader reader)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
Anyone knows how to fix this?
Thanks