protected void OutputJson(string data, string rootElementName, string arrayElementName) { switch (OutputFormat.ToLowerInvariant()) { case "json": Output(data); break; case "xml": var xml = JsonConvert.DeserializeXNode(data.StartsWith("[") ? $"{{{arrayElementName}:{data}}}" : data, rootElementName); OutputXml(xml); break; default: OutputError("format not supported"); break; } }