json作为字符串,不确定到目前为止我所做的是否也是正确的



Hi我需要这个json结果作为字符串发送

{"tickerIds":[913256135],"type":"102"}

到目前为止我有这个

"{"tickerIds":"[913354090]","type":"102"}"

问题是[913354090]不需要封装在"中。我甚至不确定我所做的是否正确。

不太确定这个使用什么标签

您没有指定如何创建Json结果,因此我无法帮助您为"[]"找到最佳解决方案,但您可以这样做以获得预期结果:

// your initial json
string yourInitialJson= "{"tickerIds":"[913354090]","type":"102"}";
// remove [] from for your [913354090]
yourInitialJson = yourInitialJson.Replace("[", "").Replace("]", "");
// escape characters with Regex method
string unescapeCharacters = System.Text.RegularExpressions.Regex.Unescape(yourInitialJson);
Console.WriteLine(unescapeCharacters);
// Result : {"tickerIds":"913354090","type":"102"}

最新更新