J
Jasper
Hi, Maybe this is off-topic, but perhaps you can help. I'm looking for ideas
on how to parse a data file.
I dont know XML but I know it parses data in text format.
I have a structured data file of the general form shown below. I dont have
any definition of the data. Basically it looks like it is hierarchical,
token/data pairs defined by brackets and square brackets.
I would like to parse this out into some sort of data object(s) in C++ so
that I can gain programmatic access to the variables.
My app is C++ so the solution must be the same. Also it must be very
lightweight and *very* fast as I must decode multiple pages in realtime.
Would adapting an XML parser to do this be a possible solution?
Any pointers/ideas/references/code snippets/observations appreciated.
TIA
Basic example showing data structure (whitespaces and carriage returns added
by me for clarity).
{
"teacher":{
"name":
"Mr Borat",
"age":
"35",
"Nationality":
"Kazakhstan"},
"Class":{
"Semester":
"Summer",
"Room":
null,
"Subject":
"Politics",
"Notes":
"We're happy, you happy?"},
"Students":
[
{
"Smith":
[{"First Name":"Mary","sex":"Female"}],
"Brown":
[{"First Name":"John","sex":"Male"}],
"Jackson":
[{"First Name":"Jackie","sex":"Female"}]
}
],
"Grades":
[
{
"Test":
[{"grade":"A","points":68},{"grade":"B","points":25},{"grade":"C","points":15}],
"Test":
[{"grade":"C","points":2},{"grade":"B","points":29},{"grade":"A","points":55}],
"Test":
[{"grade":"C","points":2},{"grade":"A","points":72},{"grade":"A","points":65}]
}
]
}
on how to parse a data file.
I dont know XML but I know it parses data in text format.
I have a structured data file of the general form shown below. I dont have
any definition of the data. Basically it looks like it is hierarchical,
token/data pairs defined by brackets and square brackets.
I would like to parse this out into some sort of data object(s) in C++ so
that I can gain programmatic access to the variables.
My app is C++ so the solution must be the same. Also it must be very
lightweight and *very* fast as I must decode multiple pages in realtime.
Would adapting an XML parser to do this be a possible solution?
Any pointers/ideas/references/code snippets/observations appreciated.
TIA
Basic example showing data structure (whitespaces and carriage returns added
by me for clarity).
{
"teacher":{
"name":
"Mr Borat",
"age":
"35",
"Nationality":
"Kazakhstan"},
"Class":{
"Semester":
"Summer",
"Room":
null,
"Subject":
"Politics",
"Notes":
"We're happy, you happy?"},
"Students":
[
{
"Smith":
[{"First Name":"Mary","sex":"Female"}],
"Brown":
[{"First Name":"John","sex":"Male"}],
"Jackson":
[{"First Name":"Jackie","sex":"Female"}]
}
],
"Grades":
[
{
"Test":
[{"grade":"A","points":68},{"grade":"B","points":25},{"grade":"C","points":15}],
"Test":
[{"grade":"C","points":2},{"grade":"B","points":29},{"grade":"A","points":55}],
"Test":
[{"grade":"C","points":2},{"grade":"A","points":72},{"grade":"A","points":65}]
}
]
}