Closed nasaonacid closed 9 years ago
Structure must have the following for the game itself:
Session id
Tree structure
When requesting a new game, the depth of the tree must be sent to allow for creation of graphical representations if need be.
When verifying the users answers, the non-answered parts of the tree structure may need to be padded with null values or special characters to indicate that they are still awaiting an answer.
also check out how other people represent trees in JSON - e.g. http://www.jstree.com/docs/json/ http://mbraak.github.io/jqTree/
Get request for a new game will return as follows:
{
"height": 3,
"difficulty": "easy",
"root": {
"content": "",
"children": [{
"content": "",
"children": []
}, {
"content": "",
"children": [{
"content": "",
"children": []
}]
}]
},
"answers": ["a", "c", "d", "b"]
}
Tree structure for a full game and creation of a new game via post will look as follows with optional height and level fields:
[{
"height": 3,
"difficulty": "easy",
"root": {
"content": "a",
"level": 0,
"children": [{
"content": "b",
"level": 1,
"children": []
}, {
"content": "c",
"level": 1,
"children": [{
"content": "d",
"level": 2,
"children": []
}]
}]
}
}]
Create json structure for api response and requests