nasaonacid / abstractAardvark

0 stars 0 forks source link

Creation of JSON structure #16

Closed nasaonacid closed 9 years ago

nasaonacid commented 9 years ago

Create json structure for api response and requests

nasaonacid commented 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.

jeremysinger commented 9 years ago

also check out how other people represent trees in JSON - e.g. http://www.jstree.com/docs/json/ http://mbraak.github.io/jqTree/

nasaonacid commented 9 years ago

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": []
            }]
        }]
    }
}]