/// <summary> /// Try to parse the given JSON representation of a PullEVSEData response. /// </summary> /// <param name="Request">The request leading to this response.</param> /// <param name="JSON">The JSON to parse.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="PullEVSEDataResponse">The parsed PullEVSEData response.</param> /// <param name="ErrorResponse">An optional error response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomPullEVSEDataResponseParser">A delegate to parse custom PullEVSEData response JSON objects.</param> public static Boolean TryParse(PullEVSEDataRequest Request, JObject JSON, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, out PullEVSEDataResponse PullEVSEDataResponse, out String ErrorResponse, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, CustomJObjectParserDelegate <PullEVSEDataResponse> CustomPullEVSEDataResponseParser = null) { try { PullEVSEDataResponse = default; if (JSON?.HasValues != true) { ErrorResponse = "The given JSON object must not be null or empty!"; return(false); } #region Parse Content [mandatory] if (!JSON.ParseMandatory("content", "EVSE data content", out JArray EVSEDataRecordsJSON, out ErrorResponse)) { return(false); } var EVSEDataRecords = new List <EVSEDataRecord>(); var Warnings = new List <Warning>(); foreach (var evseDataRecordJSON in EVSEDataRecordsJSON) { try { var ErrorResponse2 = String.Empty; if (evseDataRecordJSON is JObject evseDataRecordJObject && EVSEDataRecord.TryParse(evseDataRecordJObject, out EVSEDataRecord evseDataRecord, out ErrorResponse2)) { EVSEDataRecords.Add(evseDataRecord); } else { if (evseDataRecordJSON is JObject evseDataRecordJObject2) { ErrorResponse2 = "EVSE " + evseDataRecordJObject2["EvseID"]?.Value <String>() + ": " + ErrorResponse2; } Warnings.Add(Warning.Create(I18NString.Create(Languages.en, ErrorResponse2))); } } catch (Exception e) { var message = e.Message; if (evseDataRecordJSON is JObject evseDataRecordJObject2) { message = "EVSE " + evseDataRecordJObject2["EvseID"]?.Value <String>() + ": " + message; } Warnings.Add(Warning.Create(I18NString.Create(Languages.en, message))); } }