Reputation: 102
I am getting a string returned to my application from my gateway processor. The string contents are:
ssl_result=0
ssl_result_message=APPROVAL
ssl_txn_id=9621F9AD-E49E-4003-91BD-5C1B08569959
ssl_approval_code=N54032
ssl_cvv2_response=
ssl_avs_response=
ssl_invoice_number=123-ABC
ssl_amount=5.00
ssl_card_number=00*******0000
ssl_exp_date=0000
[email protected]
The ssl_result_message could be either "APPROVAL" or "DECLINED". I need to be able to parse the string to determine what the message was and if approved, what the ssl_approval_code is. The problem I am having is these values will be dynamic.
Upvotes: 0
Views: 448
Reputation: 35353
var dict = File.ReadLines(filename)
.Select(line=>line.Split(new char[]{'='},StringSplitOptions.RemoveEmptyEntries))
.ToDictionary(parts=>parts[0], parts=>parts.Length>1 ? parts[1] : "");
Console.WriteLine(dict["ssl_result_message"]);
if it is in a string, then
var dict = text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
.Select(line=>line.Split(new char[]{'='},StringSplitOptions.RemoveEmptyEntries))
.ToDictionary(parts=>parts[0], parts=>parts.Length>1 ? parts[1] : "");
Upvotes: 4