hierarchical JSON -> dict

    Javascriptresolved

    John J.A. Jannone's icon
    John J.A. Jannone's icon
    John J.A. Jannone
    Mar 01 2023 | 7:26 pm
    How can I get JSON like this into a dict?
    "[{\"title\":\"512-depth-ema.safetensors\",\"model_name\":\"512-depth-ema\",\"hash\":null,\"sha256\":null,\"filename\":\"/Users/johnjannone/stable-diffusion-webui/models/Stable-diffusion/512-depth-ema.safetensors\",\"config\":null},{\"title\":\"v2-1_768-ema-pruned.safetensors [dcd690123c]\",\"model_name\":\"v2-1_768-ema-pruned\",\"hash\":\"dcd690123c\",\"sha256\":\"dcd690123cfc64383981a31d955694f6acf2072a80537fdb612c8e58ec87a8ac\",\"filename\":\"/Users/johnjannone/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-ema-pruned.safetensors\",\"config\":null}]"
    I tried several approaches, and eventually made this Max monstrosity to get something that worked (attached), but it seems there's got to be an easier way...
    dict-test.maxpat
    maxpat 17.46 KB

    • tyler mazaika's icon
      tyler mazaika's icon
      tyler mazaika
      Mar 01 2023 | 8:23 pm
      Input of arrays of stuff is a pain. But life can be much easier if you can do JSON handling in javascript...
      Max Patcher
      In Max, select New From Clipboard.
      Show Text
      Share
    • John J.A. Jannone's icon
      John J.A. Jannone's icon
      John J.A. Jannone
      Mar 02 2023 | 3:02 am
      That's great - thank you Tyler! I hope the max dict suite will eventually handle hierarchical JSON better, but this will do the trick for now, and I'll study it as well :)