web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Unsecure Config – Error when parsing JSON in plugin code

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I set the unsecure config to the following JSON: 
{/DebugVirtualPlugin/:/true/} 
 
Per online jsonlint.com, it’s a valid JSON 

Trace log of the unsecure config string 
Code: Context.Trace($/unsecure: {unsecure.EscapeInterpolation()} ); 
Output: unsecure: {/DebugVirtualPlugin/:/true/} 

Trying to deserialize the JSON into the following class: 
public class UnsecureConfig 
{ 
   [JsonPropertyName(/DebugVirtualPlugin/)] 
   public string DebugVirtualPlugin { get; set; } 
} 

Code to deserialize 
var unsecureConfig = System.Text.Json.JsonSerializer.Deserialize<UnsecureConfig>(/{///DebugVirtualPlugin///:///true///}/); 

 

Error 
System.Runtime.Serialization.SerializationException: Element 'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value' contains data from a type that maps to the name 'Model.Config:UnsecureConfig'. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'UnsecureConfig' and namespace 'Model.Config'. 

 

This error happens when I am trying to deserialize in plugin code, but in a Test method, it deserializes without a problem: 
 

[TestMethod] 
public void DeserializeJson_UnsecureConfig_Test() 
{ 
   var json = /{///DebugVirtualPlugin///: ///true///}/; 
   var unsecureConfig = System.Text.Json.JsonSerializer.Deserialize<UnsecureConfig>(json); 
   Assert.IsTrue(unsecureConfig.DebugVirtualPlugin == /true/);  
} 

Any thoughts? 

I have the same question (0)
  • Suggested answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    Here is my code to deserialize the JSON.
    You can refer to the following official documentation.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Text.Json;
    using System.Text.Json.Serialization;
    namespace ConsoleApp1
    {
        internal class Program
        {
            static void Main(string[] args)
            {
                var json = @"{""DebugVirtualPlugin"":true}";
     
                var unsecureConfig = System.Text.Json.JsonSerializer.Deserialize<UnsecureConfig>(json);
     
                Console.WriteLine($"DebugVirtualPlugin: {unsecureConfig.DebugVirtualPlugin}");
            }
        }
     
        public class UnsecureConfig
        {
            [JsonPropertyName("DebugVirtualPlugin")]
            public bool DebugVirtualPlugin { get; set; }
        }
    }
     
     
    Best Regards,
    Dengliang Li
     
  • Community member Profile Picture
    5 on at
    Hi Dengliang,
     
    Thank you for responding and creating the code for this use case.
     
    I am able to do the same in a Test Method:
     
    BUT, the problem is that if you try to do this within Plugin Code, the Deserialize method does not work and throw this error:
    System.Runtime.Serialization.SerializationException: Element 'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value' contains data from a type that maps to the name 'Model.Config:UnsecureConfig'. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'UnsecureConfig' and namespace 'Model.Config'. 
     
    Any idea?
     
    Best,
    Tony

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 176

#2
ManoVerse Profile Picture

ManoVerse 158 Super User 2026 Season 1

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 57 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans