/// <summary> /// Extracts from a clean json (see <see cref="GetResultJSON(string)"/>) /// the pershot qasm results. /// </summary> /// <param name="jsonText"></param> /// <returns></returns> private static QASMExecutionResult ReadRawDataJSON(string jsonText) { if (string.IsNullOrEmpty(jsonText)) { return(null); } jsonText = jsonText.TrimStart('['); jsonText = jsonText.TrimEnd(']'); jsonText = jsonText.Replace("\"", ""); string[] rawResultCollection = jsonText.Split(','); QASMExecutionResult executionResult = new QASMExecutionResult(); foreach (string rawResult in rawResultCollection) { executionResult.Add(System.Convert.ToInt32(rawResult, 2)); } return(executionResult); }
/// <summary> /// Extracts from a clean json (see <see cref="GetResultJSON(string)"/>) /// the accumulated qasm results. /// </summary> /// <param name="jsonText"></param> /// <returns></returns> private static QASMExecutionResult ReadCountJSON(string jsonText) { if (string.IsNullOrEmpty(jsonText)) { return(null); } jsonText = jsonText.TrimStart('{'); jsonText = jsonText.TrimEnd('}'); string[] rawResultCollection = jsonText.Split(','); QASMExecutionResult executionResult = new QASMExecutionResult(); foreach (string rawResult in rawResultCollection) { string[] keyValue = rawResult.Split(':'); keyValue[0] = keyValue[0].Trim('"'); executionResult.Add(System.Convert.ToInt32(keyValue[0], 2), System.Convert.ToInt32(keyValue[1])); } return(executionResult); }