Skip to content

Instantly share code, notes, and snippets.

@abidanBrito
Created May 5, 2021 01:13
Show Gist options
  • Save abidanBrito/465571119f529c16b6a05a7a2b914d43 to your computer and use it in GitHub Desktop.
Save abidanBrito/465571119f529c16b6a05a7a2b914d43 to your computer and use it in GitHub Desktop.
StringBuilder jsonData = new StringBuilder();
jsonData.Append("[");
for (int i = 0; i < dt.Rows.Count; ++i)
{
jsonData.Append("{");
jsonData.Append("\"" + "DNI" + "\":" + "\"" + dt.Rows[i][0] + "\"" + "," + "\"" + "Name" + "\":" + "\"" + dt.Rows[i][1] + "\"" + ",");
jsonData.Append("\"" + "Telephone" + "\":" + "\"" + dt.Rows[i][2] + "\"" + "," + "\"" + "Observations" + "\":" + "\"" + dt.Rows[i][3] + "\"");
if (i == dt.Rows.Count - 1) { jsonData.Append("}"); }
else { jsonData.Append("},"); }
}
jsonData.Append("]");
string jsonArray = jsonData.ToString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment