I am passing JSON value from windows application to console application in args parameter, and trying to deserialize it in class object, but it is giving me error while doing it as below,
Unexpected character encountered while parsing value: L. Path 'Line1', line 1, position 8.
I am using JSON.NET library to do this. Below is my code,
Windows application,
Address address = new Address() { Line1 = "Line 1", Line2 = "Line 2" };
string json = JsonConvert.SerializeObject(address);
Process compiler = new Process();
compiler.StartInfo.FileName = @"D:\Learning\Console\ValidateAddress\ValidateAddress\bin\Debug\ValidateAddress.exe";
compiler.StartInfo.Arguments = json;
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();
compiler.WaitForExit();
button1.Text = compiler.StandardOutput.ReadToEnd();
Console application,
Address m = JsonConvert.DeserializeObject<Address>(args[0]);
System.IO.File.WriteAllText(@"D:\path.txt", args[0]);
Console.WriteLine(args[0]);
In console application, args[0] parameter is printing below value in text file,
{Line1:Line 1,Line2:Line 2}
In string values, it is not getting double quotes. (Line 1, instead of "Line 1")
In windows application, I am getting below string,
"{Line1:Line 1,Line2:Line 2}\r\n"
Where I need to do a change in console application during deserialisation to make it work?