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

Aris Tiru August 14, 2017

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.

5 answers

3 votes
Krzysztof Dubowik
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 26, 2018

I found that this works:

 

{noformat}

your JSON code here

{noformat}

Aris Tiru March 26, 2018

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}

Mr_ Beedell_ Roke Julian Lockhart
Contributor
October 17, 2024

Thank you! That worked for https://bugs.mojang.com/browse/MC-277669.

0 votes
Mr_ Beedell_ Roke Julian Lockhart
Contributor
October 21, 2024

You're attempting to utilize the now-deprecated inline monospace formatting:

It still is used but hasn't got the same rendering anymore. The border and background or the tag like appearance if you will is not any longer there.

What you need to do instead is use the block code formatting:

{code:json}
{
"id": "test",
"key": "testkey"
}
{code}

 

0 votes
Sonny Rajagoplan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2021

JIRA's preformatting is frankly extremely atrocious. Here is a typical workflow for me. I will use backticks to preformat; then see it doesn't work. Then click edit, but when i remove the backticks and just re-add them (yes, seriously), it magically works again.

 

Sometimes I have to use double braces, sometimes I have to use backticks. Sometimes works. Unpredicatable. Poor design. Worse implementation.

0 votes
Iris Panabaker
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 15, 2017

You can use these tools to do that

Aris Tiru August 15, 2017

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

0 votes
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 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

Aris Tiru August 15, 2017

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.

Bruce Reed
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 12, 2018

Let me add more clarity.  This question has nothing to do with JSON formatting.

The real question is about text formatting just like the <pre> html tag.

As indicated in the 3rd answer, you can use {code} or {noformat}.

Suggest an answer

Log in or Sign up to answer