Skip to content

Instantly share code, notes, and snippets.

@rohitn
rohitn / formatJSON.m
Created October 25, 2021 01:19 — forked from szhorvat/formatJSON.m
Format imported JSON for readability in Mathematica
formatJSON[json_] := formatRawJSON@rulesToAssociations[json]
rulesToAssociations[rules_] :=
Replace[rules, r : {__Rule} :> Association[r], {0, Infinity}]
basicTypeQ[_String | True | False | Null | (_?NumericQ)] = True;
basicTypeQ[_] = False;
formatRawJSON[json_] :=