Github API hit json conversion to datatable. Following is the sample json data:
[
{
"id": 132,
"description": "",
"name": "project",
"name_with_namespace": "Source Admin / project",
"path": "project",
"path_with_namespace": "root/project",
"created_at": "2019-01-18T08:10:17.594Z",
"default_branch": "master",
"tag_list": [],
"ssh_url_to_repo": "[email protected]:root/project.git",
"http_url_to_repo": "http://codecommit.companyname.com/root/project.git",
"web_url": "http://codecommit.companyname.com/root/project",
"readme_url": null,
"avatar_url": null,
"star_count": 0,
"forks_count": 0,
"last_activity_at": "2019-04-10T06:59:10.992Z",
"namespace": {
"id": 1,
"name": "root",
"path": "root",
"kind": "user",
"full_path": "root",
"parent_id": null
}
},
{
"id": 131,
"description": "",
"name": "project1",
"name_with_namespace": "Source Admin / project1",
"path": "project1",
"path_with_namespace": "root/project1",
"created_at": "2019-01-18T08:10:01.909Z",
"default_branch": "master",
"tag_list": [],
"ssh_url_to_repo": "[email protected]:root/project1.git",
"http_url_to_repo": "http://codecommit.company.com/root/project1.git",
"web_url": "http://codecommit.company.com/root/project1",
"readme_url": null,
"avatar_url": null,
"star_count": 0,
"forks_count": 0,
"last_activity_at": "2019-05-29T08:44:03.145Z",
"namespace": {
"id": 1,
"name": "root",
"path": "root",
"kind": "user",
"full_path": "root",
"parent_id": null
}
}
]
Two problem araise while converting through:
var json1 = JsonConvert.DeserializeObject<DataTable>(json);
1) because of empty array field: "tag_list":[]
Error: Unexpected JSON token when reading DataTable: EndArray. Path '[0].tag_list', line 1, position 280.
2) because of sub document: namespace
{"id":1,"name":"root","path":"root","kind":"user","full_path":"root","parent_id":null}
Error: Unexpected JSON token when reading DataTable: StartObject. Path '[0].namespace', line 1, position 555.
I don't want all columns values, only three column values:
"id":132,"name":"project",created_at":"2019-01-18T08:10:17.594Z".