指定要从生成JSON对象的Node JS函数返回的属性

时间:2017-03-15 22:34:34

标签: javascript json node.js

函数getMyObject()返回一个名为typedef struct Student{ char firstName[NAME]; char lastName[NAME]; int priority; int readingLevel; bookIds* wishlist; struct Student* next; }student; student* buildStudentList(char* studentsFile, student* head) { int i; FILE* fp; if((fp = fopen(studentsFile, "r")) == NULL) { printf("Unable to open file\n"); return 0; } student* current = NULL; char firstName[NAME], lastName[NAME]; int priority, readingLevel; while(fscanf(fp, "%s %s %d %d",firstName, lastName, &priority, &readingLevel) != EOF) { student* tempPtr = malloc(sizeof(student)); tempPtr->next = NULL; tempPtr->wishlist = NULL; strcpy(tempPtr->firstName, firstName); strcpy(tempPtr->lastName, lastName); tempPtr->priority = priority; tempPtr->readingLevel = readingLevel; if(head == NULL) { head = tempPtr; } else { current->next = tempPtr; } current = tempPtr; } fclose(fp); return head; } 的非常长的对象。我只是希望它返回一个非常具体的属性responseObject,其路径为:

mydata

我怎样才能通过这条"路径"到responseObject.data.GetNumber.GetId[1].a.dataset.mydata 以便只返回getMyObject()?该函数应该只返回属性,返回整个对象的选项然后应用" path"是不可接受的。

0 个答案:

没有答案