w3qvba
Last Updated: February 25, 2016
·
2.732K
· gongo

json format script by Emacs Lisp

example

get json from http://www.redmine.org/issues/90.json

{"issue":{"author":{"name":"Matt Jones","id":61},"status":{"name":"New","id":1},"subject":"Show deleted wiki pages or wiki files on the activity","project":{"name":"Redmine","id":1},"done_ratio":0,"custom_fields":[{"value":"","name":"Resolution","id":2}],"category":{"name":"Wiki","id":1},"created_on":"2007/08/15 02:55:00 +0200","tracker":{"name":"Feature","id":2},"description":"The problem with this, is that the Activity section is the first page I go to see if anything has happened in my project.\r\nSo someone with 'wiki delete' and 'file delete' permissions could go in, and delete pages and files. I would never know\r\nif they did this until I checked the wiki manually.\r\n\r\nWhat I would do is this:\r\n# For files added to the wiki, I would add a link to the page in the Activity section\r\n# For files deleted in the wiki, I would add a link to that wiki page in the Activity section\r\n# For wiki pages deleted, I would just add text saying what page was deleted in the Activity section. We cant link to\r\na page that no longer exists.","updated_on":"2011/03/24 10:34:35 +0100","id":90,"priority":{"name":"Normal","id":4}}}

How to

  1. Download https://gist.github.com/1789605 and eval.
  2. Run M-x json-reformat-region, format region as json string.

Result

{
    "issue": {
        "priority": {
            "id": 4,
            "name": "Normal"
        },
        "id": 90,
        "updated_on": "2011/03/24 10:34:35 +0100",
        "description": "The problem with this, is that the Activity section is the first page I go to see if anything has happened in my project.
So someone with 'wiki delete' and 'file delete' permissions could go in, and delete pages and files. I would never know
if they did this until I checked the wiki manually.

What I would do is this:
# For files added to the wiki, I would add a link to the page in the Activity section
# For files deleted in the wiki, I would add a link to that wiki page in the Activity section
# For wiki pages deleted, I would just add text saying what page was deleted in the Activity section. We cant link to
a page that no longer exists.",
        "tracker": {
            "id": 2,
            "name": "Feature"
        },
        "created_on": "2007/08/15 02:55:00 +0200",
        "category": {
            "id": 1,
            "name": "Wiki"
        },
        "custom_fields": [
            {
                "id": 2,
                "name": "Resolution",
                "value": ""
            }
        ],
        "done_ratio": 0,
        "project": {
            "id": 1,
            "name": "Redmine"
        },
        "subject": "Show deleted wiki pages or wiki files on the activity",
        "status": {
            "id": 1,
            "name": "New"
        },
        "author": {
            "id": 61,
            "name": "Matt Jones"
        }
    }
}