Jettison
  1. Jettison
  2. JETTISON-43

Human readable JSON output option

    Details

    • Type: New Feature New Feature
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.4, 1.3.1
    • Labels:
      None
    • Number of attachments :
      2

      Description

      It would be really nice if there was a way to get human readable JSON like so:
      {"myPrefix4":

      { "id": "id0", "title": "Sample item 1", "text": "This is the first preloaded sample item", "owner": "admin", "flagged": false, "number": 1, "sakaiEntity": "true", "sakaiEntity-URL": "http://localhost:8081/direct/webapp-entity/id0", "sakaiEntity-ID": "id0" }}

      instead of only the machine readable stuff like:
      {"myPrefix4":{"id":"4-one","stuff":"something","number":0,"sakaiEntity":true,"sakaiEntity-URL":"http:\/\/localhost:8001\/portal\/direct\/myPrefix4\/4-one","sakaiEntity-ID":"4-one"}}

      This would need to be optional but it would make it a lot easier for developers who need to work with the JSON to read it when there are some spaces and line breaks.

      1. JsonIndenter.java
        12 kB
        Chris Hyzer
      2. JsonIndenter.java
        10 kB
        Chris Hyzer

        Activity

        Hide
        Chris Hyzer added a comment -

        I am attaching code that you can have that I wrote which formats and indents a json string... feel free to use it, modify, throw away, whatever

        Show
        Chris Hyzer added a comment - I am attaching code that you can have that I wrote which formats and indents a json string... feel free to use it, modify, throw away, whatever
        Hide
        Chris Hyzer added a comment -

        sorry for the repeat, here is one with no dependencies, and a "main" example... if you have a test case that is wrong, feel free to let me know and I can support this part...

        Regards,
        Chris

        Show
        Chris Hyzer added a comment - sorry for the repeat, here is one with no dependencies, and a "main" example... if you have a test case that is wrong, feel free to let me know and I can support this part... Regards, Chris
        Hide
        Adrian Tarau added a comment -

        I would love to have built in formatter/indenter. Dan, would you be open for a patch which will provide support for automatic layout?

        Show
        Adrian Tarau added a comment - I would love to have built in formatter/indenter. Dan, would you be open for a patch which will provide support for automatic layout?
        Hide
        Dejan Bosanac added a comment -

        Adrian, the patch would be welcomed. Sorry for the late reply,

        Show
        Dejan Bosanac added a comment - Adrian, the patch would be welcomed. Sorry for the late reply,
        Hide
        Jochen Stiepel added a comment -

        Hi, this should be fixed in release 1.3.1. But I can't find a Class with the name JsonIndenter or something similar.
        How can I use this to format JSON ?
        Regards.

        Show
        Jochen Stiepel added a comment - Hi, this should be fixed in release 1.3.1. But I can't find a Class with the name JsonIndenter or something similar. How can I use this to format JSON ? Regards.
        Hide
        Sergey Beryozkin added a comment -

        It's called 'StringIndenter' given that this form of identation is about building the in mem representation...

        Show
        Sergey Beryozkin added a comment - It's called 'StringIndenter' given that this form of identation is about building the in mem representation...

          People

          • Assignee:
            Sergey Beryozkin
            Reporter:
            Aaron Zeckoski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: