JIRA "Preformatted" style not working when trying to format JSON data Edited

I wanted to use the Preformatted style in the comment section to apply to a JSON code.

Note: JIRA is adding the double braces when trying to apply "Preformatted" style.

{{

{

  "id": "test",

  "key": "testkey"

}

}}


But doesn't work, just shows the double curly braces.  So I thought maybe it's having problems escaping the curly brace from the JSON data, so tried to surround it first with "_", like:

{{

_{

  "id": "test",

  "key": "testkey"

}_

}}

Not working too.  Also, it seems to be removing the newline chars within the the json data so the whole thing comes out in a single line.

3 answers

0 vote
Warren Levy Community Champion Aug 15, 2017

Hi Aris

There are some good JSON validators / formatters available online, which I use. I put your JSON in to one and it wasn't happy. Removed 2 braces at the beginning and 2 at the end and it was happy e.g.

{
"id": "test",

"key": "testkey"
}

Does it matter that the JSON all shows on one line? It doesn't in the formatter, but JSON is only used as a method of transferring data, so it shouldn't matter how it looks

Thank you for your reply but...

My query is about how to keep the JSON formatting in the Comments section of JIRA, using the Preformatted style, where it encloses the block with double braces.  If it's not formatted properly, it's impossible to read it without formatting the text in another editor.

You can use these tools to do that

Similar to previous reply, so I rephrased the title and the problem description a bit.

I found that this works:

 

{noformat}

your JSON code here

{noformat}

Thanks, that indeed works though I don't see that option from the toolbar!

Also, just realized the {code} ... {code} block is much better.

{code}

{
  id: 111,
  key: "abc",
  isOk: true
}


{code}

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Sarah Schuster
Posted Mar 28, 2018 in Jira Software

Can a company’s culture make or break agile adoption?

Can a new-to-agile team survive and thrive in a non-agile culture? If so, what advice would you give to those trying to be agile in a non-agile culture? What's the key(s) to success? Share your thoug...

13,377 views 15 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you