Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Problem with double backslash in the file path after json serialization ...

$
0
0

Hello to all, i have a list of objects contain information on file including the path and I thought to provide a javascript json string, unfortunately the paths within the string after creating
the server side (asp.net mvc core) with c # they have doubled backslash character and is not due to the fact that '\' is an escape character. I've tried everything, for example:

string json = Newtonsoft.Json.JsonConvert.SerializeObject(folderTree, Newtonsoft.Json.Formatting.Indented);
json = json.Replace ("\\\\", "\\") or json = json.Replace ("\\", "")

i have this :

[{"id":"0","parent":"#","text":"server","level":0,"folderName":"server","folderPath":"Z:\\csi\\server","fileItems":[{"fileName":"serverfile1","filePath":"Z:\\csi\\server\\serverfile1.txt","fileExtension":".txt"},"fileName":"serverfile2","filePath":"Z:\\csi\\server\\serverfile2.txt","fileExtension":".txt"},		 {"fileName":"serverfile3","filePath":"Z:\\csi\\server\\serverfile3.txt","fileExtension":".txt"}]
}]

I need this :

[{"id":"0","parent":"#","text":"server","level":0,"folderName":"server","folderPath":"Z:\csi\server","fileItems":[{"fileName":"serverfile1","filePath":"Z:\csi\server\serverfile1.txt","fileExtension":".txt"},"fileName":"serverfile2","filePath":"Z:\csi\server\serverfile2.txt","fileExtension":".txt"},		 
{"fileName":"serverfile3","filePath":"Z:\csi\server\serverfile3.txt","fileExtension":".txt"}] }]


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>