I have a string (text) that I would like to convert using a JSON parser so that it is javascript friendly.
In my view page I have some javascript that looks like:
var site = {
strings: {
addToCart: @someValue,
So @someValue should be javascript safe like double quotes, escaped chars if needed etc.
That value @someValue is a string, but it has to be javascript friendly so I want to parse it using JSON.
Does the new System.Text.Json have something?
I tried this:
return System.Text.Json.JsonDocument.Parse(input).ToString();
But this doesnt' work because my text is just a string, not a JSON string.
Is there another way to parse something?