Skip to content

Python dotGraph failed to parse JSON #235

Open
@DeDiamondPro

Description

@DeDiamondPro

Hi,

I was trying to use the dotGraph type with python, unfortunately it seems like the JSON parser is unable to parse it.
Code to replicate, text is taken from your playground example:

import json

text = "\ndigraph G {\n    subgraph cluster_0 {\n      style=filled;\n      color=lightgrey;\n      node [style=filled,color=white];\n      a0 -> a1 -> a2 -> a3;\n      label = \"process #1\";\n    }\n  \n    subgraph cluster_1 {\n      node [style=filled];\n      b0 -> b1 -> b2 -> b3;\n      label = \"process #2\";\n      color=blue\n    }\n    start -> a0;\n    start -> b0;\n    a1 -> b3;\n    b2 -> a3;\n    a3 -> a0;\n    a3 -> end;\n    b3 -> end;\n  \n    start [shape=Mdiamond];\n    end [shape=Msquare];\n}\n"
value = json.dumps({"kind": {"dotGraph": True}, "text": text})

print(value)

This fails to parse with the following error:
image

I think this is caused by the fact that the JSON it is trying to parse seems to be double escaped, for example I would expect it to be escaped like this: label = \"process #1\", this is also what happens if I print the string, but instead the string it is trying to parse contains label = \\"process #1\\", which causes the " to not be escaped and I think that is what is causing parsing to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions