Home > Net >  JSON serialization for dictionary special character escaping deal with.net 5.0 CORE
JSON serialization for dictionary special character escaping deal with.net 5.0 CORE

Time:12-21

JSON data: the original
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
{
"Aa" :
{" a1 ":" aa11, "
"A2" : "https:\/\/www.abc.com \/asfasd8asfad
"},
"Bb" : "bbbbbbbbbasdfasdxxx}
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
If JAVA use a dictionary can get two keys, aa and bb. Aa to string value and JSON originally,
Is this:
{" a1 ":" aa11, "
"A2" : "https:\/\/www.abc.com \/asfasd8asfad
"}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
But I use c # language in the same way to get the key values of aa and bb, bb is the same string, this need not speak,
But the value of aa is this:
{" a1 ":" aa11, "
"A2" : "https://www.abc.com/asfasd8asfad"
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Want to know how to get the original data, use a dictionary, do not escape, because I don't know if it is only the character escaping, so must want to know the solution,
My c # code is as follows:
Dictionary DicData=https://bbs.csdn.net/topics/JsonSerializer.Deserialize (strData);//to convert a JSON dictionary
Because when it is turned off, the data can't turn back, behind
Not even if I add the parameter
JsonSerializerOptions jso=new JsonSerializerOptions ()
{
Encoder=JavaScriptEncoder UnsafeRelaxedJsonEscaping,//solve Chinese garbled - not escape Unicode data
IgnoreNullValues=true,//to null
};
This plus also not line,

Is actually a word, don't escape the JSON object into character; [remind is a JSON object is not string aa]
I want to get the data "https:\/\/www.abc.com \/asfasd8asfad
"Not to get "https://www.abc.com/asfasd8asfad"


CodePudding user response:

How do you confirm "raw data"? If the original data is inside \/so never considered a/c #, only may be your c # to achieve string strData code was wrong,

CodePudding user response:

Post your screenshot, see you how, in what debug window to determine the "raw data"?

CodePudding user response:

refer to the second floor interacting in a professional developer response:
post your screenshot, see how are you, what in debug window to determine the "raw data"?

Thank you for reminding me, but I'm the raw data is acquired, I break out, so the original data is not wrong,
The following is my code,

CodePudding user response:


The last line is I want to get the data, the key is in the serialization is wrong there, I don't know how to change
  •  Tags:  
  • C#
  • Related