Paste: Massage some JSON

Author: Revolucent
Mode: factor
Date: Thu, 20 Sep 2012 04:33:57
Plain Text |
USING: arrays assocs command-line io io.encodings.utf8 io.files kernel locals prettyprint json.reader json.writer sequences ;

IN: todd

CONSTANT: location-subkeys { "blurb" "locationcity" } ! These are just examples.

(command-line) rest [
    utf8 file-contents json> "sections" swap at first "data" swap at [| place |
        H{  } :> location
        location-subkeys [| key |
            key place at key location set-at
            key place delete-at
        ] each
        location "location" place set-at
        place
    ] map
] map concat json-print

New Annotation

Summary:
Author:
Mode:
Body: