I am trying to get the value of a key in my JSON data however I am receiving a question mark as response.
My config.json
file:
{
currency_sign: "£"
}
My code:
public static void readConfig()
{
var file = File.ReadAllText("config.json");
var file2 = JObject.Parse(file);
string currency = file2.SelectToken("currency_sign").Value<string>();
Console.WriteLine("Currency: " + currency);
}
Output of my code:
Currency: ?
I have also tried encoding the string:
byte[] bytes = Encoding.Default.GetBytes(currency);
currency = Encoding.UTF8.GetString(bytes);
However the output was exactly the same.
Why is my code returning ?
instead of £
and how can I fix this?