Created at 06 Sep 2017, 10:43
Print
06 Sep 2017, 10:43
Hi,
I'm reading a json string from a file like following:
{"aaa": 1}
When I try to print the file string I get string format error because of the {}. How can I print this string?
Thanks
Replies
yoannes
06 Sep 2017, 11:13
Hi,
Thanks for your answer. Below example of file
{"symbol":"EURUSD","dir":0,"eTime":"2017-09-06 08:01:17.36","cTime":"2017-09-06 08:01:21.16","ePrice":1.19339,"cPrice":1.19339,"volume":1000,"comm":-0.08,"swap":0.0,"net":-0.08,"comment":"","label":""} {"symbol":"EURUSD","dir":0,"eTime":"2017-09-06 08:01:27.90","cTime":"2017-09-06 08:01:30.31","ePrice":1.19352,"cPrice":1.19345,"volume":1000,"comm":-0.08,"swap":0.0,"net":-0.15,"comment":"","label":""}
Trying to read file:
string[] lines = System.IO.File.ReadAllLines(pathOrders); foreach (string line in lines) { Print(p); }
this is the error I get
06/09/2017 08:11:18.992 | Crashed in OnStart with FormatException: Input string was not in a correct format.
So i'm using this workaround to print my content:
string[] lines = System.IO.File.ReadAllLines(pathOrders); foreach (string line in lines) { string p = line.Replace("{", "{{"); p = p.Replace("}", "}}"); Print(p); }
But is there a better way of doing it?
@yoannes
Spotware
06 Sep 2017, 11:07
Dear yoannes,
Can you please provide us with the code you use to print this string so that we can advise accordingly?
Best Regards,
cTrader Team
@Spotware