ani-hovhannisyan/kanji-visualization

Define JSON format

Closed this issue · 7 comments

wowry commented

Define JSON format that contains node, link and info.

wowry commented

Format

{
    "nodes": {
        "id": string,
        "isMain"?: boolean,
    }[],
    "links": {
        "source": string,
        "target": string
    }[],
    "info": {
        "id": string,
        "isMain"?: boolean,
        "onyomi": string[],
        "kunyomi": string[],
        "meaning": string[]
    }[]
}

Example

{
    "nodes": [ 
        { 
            "id": "",
            "isMain": true
        },
        {
            "id": ""
        }
    ],
    "links": [
        {
            "source": "",
            "target": ""
        }
    ],
    "info": [
        {
            "id": "",
            "isMain": true,
            "onyomi": ["サン", "セン"],
            "kunyomi": ["ヤマ"],
            "meaning": ["mountain"]
        },
        {
            "id": "",
            "onyomi": ["", "トウ"],
            "kunyomi": ["ノボる"],
            "meaning": ["ascend", "climb up"]
        }
    ]
}
wowry commented
"links": [
    {
        "source": "",
        "target": ""
    }
],

Here, the values of source and target are the node IDs. In this case, the arrow will be connected from "登" to "山", like this: 登→山.

wowry commented

My understanding is that nodes and links will be generated in GraphController, and info will be generated in InfoController. And then, we can combine them into a single JSON in main.py, and send it to the frontend.

wowry commented
"nodes": [ 
    { 
      "id": "",
      "isMain": true
    },
    { 
      "id": ""
    }
],

Please set "isMain": true if it is the main node, and do the same for info.

Sorry I implemented json response temporary.
But don't care. you can update it.
#53

wowry commented

OK, thanks. I'll check it.

The format is ok, I constructed same in GC (GraphController) like this

{
		"nodes": [{
			"id": "山",
			"isMain": "true"
		}, {
			"id": "陰"
		}, {
			"id": "治"
		}, {
			"id": "開"
		}, {
			"id": "道"
		}, {
			"id": "須"
		}, {
			"id": "弥"
		}, {
			"id": "奥"
		}, {
			"id": "青"
		}, {
			"id": "富"
		}, {
			"id": "士"
		}, {
			"id": "脈"
		}, {
			"id": "火"
		}, {
			"id": "登"
		}, {
			"id": "岩"
		}, {
			"id": "事"
		}],
		"links": [{
			"source": "山",
			"target": "陰"
		}, {
			"source": "治",
			"target": "山"
		}, {
			"source": "開",
			"target": "山"
		}, {
			"source": "山",
			"target": "道"
		}, {
			"source": "須",
			"target": "弥"
		}, {
			"source": "弥",
			"target": "山"
		}, {
			"source": "奥",
			"target": "山"
		}, {
			"source": "青",
			"target": "山"
		}, {
			"source": "富",
			"target": "士"
		}, {
			"source": "士",
			"target": "山"
		}, {
			"source": "山",
			"target": "脈"
		}, {
			"source": "火",
			"target": "山"
		}, {
			"source": "登",
			"target": "山"
		}, {
			"source": "岩",
			"target": "山"
		}, {
			"source": "山",
			"target": "火"
		}, {
			"source": "火",
			"target": "事"
		}]
	}

Closing because both side have more and less defined the format.