formatting adjacency list into json object