prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  jit json import/export
  I would consider the functions `jit_data` and `jit_graph` to be their inverses, so that
  ```
  import networkx as nx
  nx.jit_graph(nx.jit_data(nx.Graph()))
  ```
  works.
  
  Instead, it produces a TypeError (nx 2.2), because jit_data is a function `nx graph -> json string`, while jit_graph is a function `json object -> nx graph`, so that the correct program would be
  ```
  import networkx as nx
  import json
  nx.jit_graph(json.loads(nx.jit_data(nx.Graph())))
  ```
  
  This is documented, but in my view unexpected and incoherent behavior. I'm pretty new to networkx and are not familiar with your design philosophy, but see the options
  * to add a clarifying note in the documentation OR
  * return the json object in `jit_data` OR
  * make use of the json.loads function in `jit_graph`.
  
  What are your opinions on this?
  I am willing to submit a PR (but probably it is just easier for you to make that oneline-commit, so that's also fine :))
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `networkx/readwrite/json_graph/jit.py`
  Content:
  ```
  1 #    Copyright (C) 2011-2019 by
  2 #    Aric Hagberg <hagberg@lanl.gov>
  3 #    Dan Schult <dschult@colgate.edu>
  4 #    Pieter Swart <swart@lanl.gov>
  5 #    All rights reserved.
  6 #    BSD license.
  7 
  8 """
  9 Read and write NetworkX graphs as JavaScript InfoVis Toolkit (JIT) format JSON.
  10 
  11 See the `JIT documentation`_ for more examples.
  12 
  13 Format
  14 ------
  15 var json = [
  16   {
  17     "id": "aUniqueIdentifier",
  18     "name": "usually a nodes name",
  19     "data": {
  20       "some key": "some value",
  21       "some other key": "some other value"
  22      },
  23     "adjacencies": [
  24     {
  25       nodeTo:"aNodeId",
  26       data: {} //put whatever you want here
  27     },
  28     'other adjacencies go here...'
  29   },
  30 
  31   'other nodes go here...'
  32 ];
  33 .. _JIT documentation: http://thejit.org
  34 """
  35 
  36 import json
  37 import networkx as nx
  38 from networkx.utils.decorators import not_implemented_for
  39 
  40 __all__ = ['jit_graph', 'jit_data']
  41 
  42 
  43 def jit_graph(data, create_using=None):
  44     """Read a graph from JIT JSON.
  45 
  46     Parameters
  47     ----------
  48     data : JSON Graph Object
  49 
  50     create_using : Networkx Graph, optional (default: Graph())
  51         Return graph of this type. The provided instance will be cleared.
  52 
  53     Returns
  54     -------
  55     G : NetworkX Graph built from create_using if provided.
  56     """
  57     if create_using is None:
  58         G = nx.Graph()
  59     else:
  60         G = create_using
  61         G.clear()
  62 
  63     for node in data:
  64         G.add_node(node['id'], **node['data'])
  65         if node.get('adjacencies') is not None:
  66             for adj in node['adjacencies']:
  67                 G.add_edge(node['id'], adj['nodeTo'], **adj['data'])
  68     return G
  69 
  70 
  71 @not_implemented_for('multigraph')
  72 def jit_data(G, indent=None):
  73     """Returns data in JIT JSON format.
  74 
  75     Parameters
  76     ----------
  77     G : NetworkX Graph
  78 
  79     indent: optional, default=None
  80         If indent is a non-negative integer, then JSON array elements and object
  81         members will be pretty-printed with that indent level. An indent level
  82         of 0, or negative, will only insert newlines. None (the default) selects
  83         the most compact representation.
  84 
  85     Returns
  86     -------
  87     data: JIT JSON string
  88     """
  89     json_graph = []
  90     for node in G.nodes():
  91         json_node = {
  92             "id": node,
  93             "name": node
  94         }
  95         # node data
  96         json_node["data"] = G.nodes[node]
  97         # adjacencies
  98         if G[node]:
  99             json_node["adjacencies"] = []
  100             for neighbour in G[node]:
  101                 adjacency = {
  102                     "nodeTo": neighbour,
  103                 }
  104                 # adjacency data
  105                 adjacency["data"] = G.edges[node, neighbour]
  106                 json_node["adjacencies"].append(adjacency)
  107         json_graph.append(json_node)
  108     return json.dumps(json_graph, indent=indent)
  109
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/networkx/readwrite/json_graph/jit.py b/networkx/readwrite/json_graph/jit.py
  --- a/networkx/readwrite/json_graph/jit.py
  +++ b/networkx/readwrite/json_graph/jit.py
  @@ -60,6 +60,9 @@
           G = create_using
           G.clear()
   
  +    if nx.utils.is_string_like(data):
  +        data = json.loads(data)
  +
       for node in data:
           G.add_node(node['id'], **node['data'])
           if node.get('adjacencies') is not None:
  @@ -77,10 +80,10 @@
       G : NetworkX Graph
   
       indent: optional, default=None
  -        If indent is a non-negative integer, then JSON array elements and object
  -        members will be pretty-printed with that indent level. An indent level
  -        of 0, or negative, will only insert newlines. None (the default) selects
  -        the most compact representation.
  +        If indent is a non-negative integer, then JSON array elements and
  +        object members will be pretty-printed with that indent level.
  +        An indent level of 0, or negative, will only insert newlines.
  +        None (the default) selects the most compact representation.
   
       Returns
       -------
  
verification_info: {"golden_diff": "diff --git a/networkx/readwrite/json_graph/jit.py b/networkx/readwrite/json_graph/jit.py\n--- a/networkx/readwrite/json_graph/jit.py\n+++ b/networkx/readwrite/json_graph/jit.py\n@@ -60,6 +60,9 @@\n         G = create_using\n         G.clear()\n \n+    if nx.utils.is_string_like(data):\n+        data = json.loads(data)\n+\n     for node in data:\n         G.add_node(node['id'], **node['data'])\n         if node.get('adjacencies') is not None:\n@@ -77,10 +80,10 @@\n     G : NetworkX Graph\n \n     indent: optional, default=None\n-        If indent is a non-negative integer, then JSON array elements and object\n-        members will be pretty-printed with that indent level. An indent level\n-        of 0, or negative, will only insert newlines. None (the default) selects\n-        the most compact representation.\n+        If indent is a non-negative integer, then JSON array elements and\n+        object members will be pretty-printed with that indent level.\n+        An indent level of 0, or negative, will only insert newlines.\n+        None (the default) selects the most compact representation.\n \n     Returns\n     -------\n", "issue": "jit json import/export\nI would consider the functions `jit_data` and `jit_graph` to be their inverses, so that\r\n```\r\nimport networkx as nx\r\nnx.jit_graph(nx.jit_data(nx.Graph()))\r\n```\r\nworks.\r\n\r\nInstead, it produces a TypeError (nx 2.2), because jit_data is a function `nx graph -> json string`, while jit_graph is a function `json object -> nx graph`, so that the correct program would be\r\n```\r\nimport networkx as nx\r\nimport json\r\nnx.jit_graph(json.loads(nx.jit_data(nx.Graph())))\r\n```\r\n\r\nThis is documented, but in my view unexpected and incoherent behavior. I'm pretty new to networkx and are not familiar with your design philosophy, but see the options\r\n* to add a clarifying note in the documentation OR\r\n* return the json object in `jit_data` OR\r\n* make use of the json.loads function in `jit_graph`.\r\n\r\nWhat are your opinions on this?\r\nI am willing to submit a PR (but probably it is just easier for you to make that oneline-commit, so that's also fine :))\n", "before_files": [{"content": "#    Copyright (C) 2011-2019 by\n#    Aric Hagberg <hagberg@lanl.gov>\n#    Dan Schult <dschult@colgate.edu>\n#    Pieter Swart <swart@lanl.gov>\n#    All rights reserved.\n#    BSD license.\n\n\"\"\"\nRead and write NetworkX graphs as JavaScript InfoVis Toolkit (JIT) format JSON.\n\nSee the `JIT documentation`_ for more examples.\n\nFormat\n------\nvar json = [\n  {\n    \"id\": \"aUniqueIdentifier\",\n    \"name\": \"usually a nodes name\",\n    \"data\": {\n      \"some key\": \"some value\",\n      \"some other key\": \"some other value\"\n     },\n    \"adjacencies\": [\n    {\n      nodeTo:\"aNodeId\",\n      data: {} //put whatever you want here\n    },\n    'other adjacencies go here...'\n  },\n\n  'other nodes go here...'\n];\n.. _JIT documentation: http://thejit.org\n\"\"\"\n\nimport json\nimport networkx as nx\nfrom networkx.utils.decorators import not_implemented_for\n\n__all__ = ['jit_graph', 'jit_data']\n\n\ndef jit_graph(data, create_using=None):\n    \"\"\"Read a graph from JIT JSON.\n\n    Parameters\n    ----------\n    data : JSON Graph Object\n\n    create_using : Networkx Graph, optional (default: Graph())\n        Return graph of this type. The provided instance will be cleared.\n\n    Returns\n    -------\n    G : NetworkX Graph built from create_using if provided.\n    \"\"\"\n    if create_using is None:\n        G = nx.Graph()\n    else:\n        G = create_using\n        G.clear()\n\n    for node in data:\n        G.add_node(node['id'], **node['data'])\n        if node.get('adjacencies') is not None:\n            for adj in node['adjacencies']:\n                G.add_edge(node['id'], adj['nodeTo'], **adj['data'])\n    return G\n\n\n@not_implemented_for('multigraph')\ndef jit_data(G, indent=None):\n    \"\"\"Returns data in JIT JSON format.\n\n    Parameters\n    ----------\n    G : NetworkX Graph\n\n    indent: optional, default=None\n        If indent is a non-negative integer, then JSON array elements and object\n        members will be pretty-printed with that indent level. An indent level\n        of 0, or negative, will only insert newlines. None (the default) selects\n        the most compact representation.\n\n    Returns\n    -------\n    data: JIT JSON string\n    \"\"\"\n    json_graph = []\n    for node in G.nodes():\n        json_node = {\n            \"id\": node,\n            \"name\": node\n        }\n        # node data\n        json_node[\"data\"] = G.nodes[node]\n        # adjacencies\n        if G[node]:\n            json_node[\"adjacencies\"] = []\n            for neighbour in G[node]:\n                adjacency = {\n                    \"nodeTo\": neighbour,\n                }\n                # adjacency data\n                adjacency[\"data\"] = G.edges[node, neighbour]\n                json_node[\"adjacencies\"].append(adjacency)\n        json_graph.append(json_node)\n    return json.dumps(json_graph, indent=indent)\n", "path": "networkx/readwrite/json_graph/jit.py"}], "after_files": [{"content": "#    Copyright (C) 2011-2019 by\n#    Aric Hagberg <hagberg@lanl.gov>\n#    Dan Schult <dschult@colgate.edu>\n#    Pieter Swart <swart@lanl.gov>\n#    All rights reserved.\n#    BSD license.\n\n\"\"\"\nRead and write NetworkX graphs as JavaScript InfoVis Toolkit (JIT) format JSON.\n\nSee the `JIT documentation`_ for more examples.\n\nFormat\n------\nvar json = [\n  {\n    \"id\": \"aUniqueIdentifier\",\n    \"name\": \"usually a nodes name\",\n    \"data\": {\n      \"some key\": \"some value\",\n      \"some other key\": \"some other value\"\n     },\n    \"adjacencies\": [\n    {\n      nodeTo:\"aNodeId\",\n      data: {} //put whatever you want here\n    },\n    'other adjacencies go here...'\n  },\n\n  'other nodes go here...'\n];\n.. _JIT documentation: http://thejit.org\n\"\"\"\n\nimport json\nimport networkx as nx\nfrom networkx.utils.decorators import not_implemented_for\n\n__all__ = ['jit_graph', 'jit_data']\n\n\ndef jit_graph(data, create_using=None):\n    \"\"\"Read a graph from JIT JSON.\n\n    Parameters\n    ----------\n    data : JSON Graph Object\n\n    create_using : Networkx Graph, optional (default: Graph())\n        Return graph of this type. The provided instance will be cleared.\n\n    Returns\n    -------\n    G : NetworkX Graph built from create_using if provided.\n    \"\"\"\n    if create_using is None:\n        G = nx.Graph()\n    else:\n        G = create_using\n        G.clear()\n\n    if nx.utils.is_string_like(data):\n        data = json.loads(data)\n\n    for node in data:\n        G.add_node(node['id'], **node['data'])\n        if node.get('adjacencies') is not None:\n            for adj in node['adjacencies']:\n                G.add_edge(node['id'], adj['nodeTo'], **adj['data'])\n    return G\n\n\n@not_implemented_for('multigraph')\ndef jit_data(G, indent=None):\n    \"\"\"Returns data in JIT JSON format.\n\n    Parameters\n    ----------\n    G : NetworkX Graph\n\n    indent: optional, default=None\n        If indent is a non-negative integer, then JSON array elements and\n        object members will be pretty-printed with that indent level.\n        An indent level of 0, or negative, will only insert newlines.\n        None (the default) selects the most compact representation.\n\n    Returns\n    -------\n    data: JIT JSON string\n    \"\"\"\n    json_graph = []\n    for node in G.nodes():\n        json_node = {\n            \"id\": node,\n            \"name\": node\n        }\n        # node data\n        json_node[\"data\"] = G.nodes[node]\n        # adjacencies\n        if G[node]:\n            json_node[\"adjacencies\"] = []\n            for neighbour in G[node]:\n                adjacency = {\n                    \"nodeTo\": neighbour,\n                }\n                # adjacency data\n                adjacency[\"data\"] = G.edges[node, neighbour]\n                json_node[\"adjacencies\"].append(adjacency)\n        json_graph.append(json_node)\n    return json.dumps(json_graph, indent=indent)\n", "path": "networkx/readwrite/json_graph/jit.py"}]}