Kru
Random Name generator.
Fixed it, I had to re-read your above statement.
This solved it.
string jsonfile = File.ReadAllText(@"C:\Users\Home\Documents\CSharp\HelloWorld\RandomName\CombineFirstNameDb.json");
var sample = JsonSerializer.Deserialize<string[]>(jsonfile);
Console.WriteLine(sample[0]);
31 replies
Random Name generator.
baby steps...
I changed it to use this
string jsonfile = File.ReadAllText(@"C:\Users\Home\Documents\CSharp\HelloWorld\RandomName\CombineFirstNameDb.json");
string sample = JsonSerializer.Deserialize<string>(jsonfile);
Console.WriteLine(sample[0]);
Getting error below. I did confirm no error on json file that's loaded in VS and online as well.
System.Text.Json.JsonException: 'The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 1.'
InvalidOperationException: Cannot get the value of a token type 'StartArray' as a string.
31 replies
Block of code
oh wow, this blew up. I did some digging around and found out that, VS Studio does not return the {} in the code block. See below. There are short cut you can use but no easy way to do it, unless you do the whole code block using TAB, TAB.
https://www.youtube.com/watch?v=1hmF00u2uF4
33 replies