Omnigraffle support for mapping JSON relationships

I was told the tool can import JSON by the sellers, if not I need to send it back.

Hi there, I’m afraid OmniGraffle is not able to directly import JSON. You may, however, be able to use something like this to convert a JSON file into a Graphiz file, which OmniGraffle is capable of importing. Another alternative may be this Applescript, which takes a JSON file, and draws it in OmniGraffle.

Hope this helps!

Hi there, I’m afraid OmniGraffle is not able to directly import JSON

Well, perhaps not strictly true …

If you use OmniGraffle’s JavaScript for Automation scripting interface you can read JSON directly:

JSON.parse(strJSON) --> JavaScript object.

Once you have the JavaScript object though, you still have to script the graphic creation with it.

If you are going to be working with a lot of JSON, D3js might be a better long-term route. It directly supports the kind of tree layout created by the AppleScript linked above.

For a basic illustration of the kind of script that might be involved, see:

Sorry draft8 - I get an unrecognised token ‘/’ error in the ver 0.06c

Otherwise this would have been amazing for me…
Admit it might be user error on my side

Any pointers appreciated

Seems to be working here.

Some things to check:

  • Make sure you have copied all of the source code (sometimes sth gets left out in copy paste)
  • If you are running it from Script Editor, make sure you have chosen JavaScript rather than Applescript in the pull-down at top left.
  • What version of OmniGraffle are you using ?

Thanks. Tried a new copy paste of code and can now parse the JSON so assume error was mine
I get a ‘Error -1700: Can’t convert types.’ but can live with that

Omnigraffle 7 (app.version 177.2.0.282951)

Appreciate your work

Good !

The ‘can’t convert types’ has appeared with Ver 7 - perhaps a change in the scripting dictionary - I have asked.

You should be able to eliminate it by editing a line towards the end. Change:

cnv.layout(graphics);

to

cnv.layout();
1 Like