我有JSON格式的回复。等级:
string grade_json = GetResponse(sign(grade_url));
var grade = JObject.Parse(grade_json).SelectTokens("['course_units_grades'].*.*.['value_symbol']");
响应
4
3
3,5
5
pass
...
和课程:
string course_json = GetResponse(sign(courses_url));
var course_title = JObject.Parse(course_json).SelectTokens("['course_editions'].*.[*].['course_name'].['en']");
响应:
Preparation for bachelor exam
Work experience
OHS training
...
但问题是,答案中的前两个年级是第一门课程(讲课和上课),后两个年级是第二门课程,依此类推:
4 - Preparation for bachelor exam (Lecture grade)
3 - Preparation for bachelor exam (class grade)
3,5 - Work experience (Lecture grade)
5 - Work experience (class grade)
pass - OHS training (this is the exception, It has just one not-number value)
...
所以当我尝试在这里使用el.A.next
或el.A.ElementAt<>
时:
foreach (var el in grade.Zip(course_title, (a, b) => new { A = a, B = b }))
{
SqlCommand myCommand = new SqlCommand("INSERT INTO Grades (lecture_grade, class_grade, course_title) Values ('" + el.A + "','" + el.A + "','" + el.B + "')", myConnection);
myCommand.ExecuteNonQuery();
}
它不起作用。为了使OHS training
变得复杂而不是与之相关的数值,这是棺材中的最后一个钉子。觉得我被困在这里。我非常感谢你能给我的任何帮助
编辑:
是的,有常见的id值。这是原始回复中的前两个课程:
{
"course_editions": {
"2014/SL": [
{
"course_id": "06-DEGZLI0",
"term_id": "2014/SL",
"course_name": {
"en": "Preparation for bachelor exam",
}
},
{
"course_id": "06-DPRALW0",
"term_id": "2014/SL",
"course_name": {
"en": "Work experience",
}
},
{
要获得成绩,我需要使用两个所需的字段/(网址参数)构建一个网址:course_id
和term_id
,所以f.e。对于第一门课程,我会得到这样的回答(是的,我错过了只有一个等级的课程):
{
"course_units_grades": {
"159715": {
"1": {
"value_symbol": "4",
"exam_session_number": 1,
"exam_id": 198172,
"value_description": {
"en": "good",
}
},
"2": null
}
},
"course_grades": null
}
所以,是的,有共同的id值。