This is the first JSON string:
{
"ContractID": 140,
"EndpointIdentifier": "24.2452",
"ErrorMessage": "",
"LogFileCollection": [
"C:/Gaston/GrandScheme/MicroLog4.txt",
"C:/Gaston/Grandscheme/MicroLog2.txt"
],
"MethodName": "TestModeExit",
"OperationBegan": "/Date(092120-0400)/",
"OperationCompleted": "/Date(092120-0400)/",
"OperationID": 1,
"Outcome": 0,
"Parameters": [
{
"Name": "ESPN",
"Value": "23.4.39447",
"VariableType": "System.String"
}
],
}
And my second JSON file:
{
"CellRelayESN": "VR-[26::AB::]",
"CellRelaySerialNumber": "[26::AB::]",
"ContractID": 0,
"DeviceClassName": "GastonGrand",
"EndpointIdentifier": "2.3532.432",
"ErrorMessage": "",
"IsAuthenticated": true,
"IsRegistrationProcessComplete": false,
"LastDeregistered": "/Date(092120-0500)/",
"LastRead": "/Date(092120-0500)/",
"LogFileCollection": [],
"MethodName": "RegistrationInformation",
"OperationBegan": "/Date(092120)/",
"OperationCompleted": "/Date(092120)/",
"OperationID": 2,
"Outcome": 0,
"Parameters": [
{
"Name": "jobManager",
"Value": "jobFoundYesOrNo",
"VariableType": "String"
},
{
"Name": "ESPN",
"Value": "2.16.839447",
"VariableType": "String"
}
],
"ReturnType": "RegistrationInfoResult",
"Server": "Host-1",
"ServiceTypeID": 1,
"Status": "Registered",
"TestRunID": 3206,
"TokenID": null
}
What I have tried:
Currently I am storing these two JSON files into one single columned DataTable that I later convert into a string to be parse with JToken.Parse. However, when I do try to parse it, I encounter the error:
Additional text encountered after finished reading JSON content: {. Path '', line 2, position 0.'
at the
JToken token = JToken.Parse(table);
line. I am wondering, how do I correctly combine these two JSON files into the same string so it can be correctly parse? Here's the rest of my code:
public static List<string> CleanOperationsTable(string liteConString)
{
List<string> cleanedList = new List<string>();
SQLiteConnection liteCon = new SQLiteConnection(liteConString);
liteCon.Open();
DataTable dtbl = new DataTable();
string select = "SELECT ResponseBody FROM Operations LIMIT 2";
SQLiteCommand cmd = new SQLiteCommand(select, liteCon);
SQLiteDataAdapter sqliteDAP = new SQLiteDataAdapter(cmd);
sqliteDAP.Fill(dtbl);
string table = string.Join(Environment.NewLine, dtbl.Rows.OfType<DataRow>().Select(x => string.Join(" ; ", x.ItemArray)));
JToken token = JToken.Parse(table);
return cleanedList;
}