Hanvon FaceID result String Parsing



I need little help in string parsing... Here's he result string from FaceID:



Return(result=\"success\" dev_id=\"6714113100001517\" total=\"24\"\r\n
time=\"2014-06-16 17:56:44\" id=\"399\" name=\"\" workcode=\"0\"
status=\"0\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-06-16 17:57:45\" id=\"399\" name=\"\" workcode=\"0\"
status=\"0\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-06-16 17:57:58\" id=\"399\" name=\"\" workcode=\"0\"
status=\"2\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-06-16 17:58:02\" id=\"399\" name=\"\" workcode=\"0\"
status=\"1\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-06-16 17:58:04\" id=\"399\" name=\"\" workcode=\"0\"
status=\"0\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-06-16 17:58:19\" id=\"399\" name=\"\" workcode=\"0\"
status=\"2\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-11-29 13:23:36\" id=\"399\" name=\"\" workcode=\"0\"
status=\"0\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-11-29 13:23:46\" id=\"399\" name=\"\" workcode=\"0\"
status=\"2\" authority=\"0X55\" card_src=\"from_check\"\r\n
time=\"2014-11-29 13:23:49\" id=\"399\" name=\"\" workcode=\"0\"
status=\"0\" authority=\"0X55\" card_src=\"from_check\"\r\n)


I know how to loop through the string and matching tokens, but I wonder if there could be any regex for this type of string? Or maybe if it's easy to convert it to XML or JSON? If so, what will be better in performance?


I want separate values for Time, ID, Name, Workcode, status, authority, card_src — for example a list or collection of objects.


No comments:

Post a Comment