Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a custom field to store the value in JSON and rest api response as JSON too

Ibrahim Kasim
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!
December 2, 2019

Data Saved:

Preview Data 

Expected output:

{ "region" : "india", "dev": "inhouse", "localPath": "D:\\s3-downloads\\", "Name" : "test-1.0.8.zip", "FolderLoc": "D:\\s3-downloads\\dev", "FileName": "D:\\s3-downloads\\dev\\Archive" }

Actual Output:

{
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "{"
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "\"region\" : \"india\","
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "\"dev\": \"inhouse\","
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "\"localPath\": \"D:\\\\s3-downloads"
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "\","
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "\"Name\" : \"test-1.0.8.zip\","
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "\"FolderLoc\": \"D:\\\\s3-downloads"
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "dev\","
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "\"FileName\": \"D:\\\\s3-downloads\\\\dev"
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "Archive\""
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "}"
}
]
}
]
}

 

 

1 answer

0 votes
Nic Brough -Adaptavist-
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.
December 3, 2019

The API already returns data in JSON format.

If you want to store as JSON, write JSON into a text field.  If you want plain text, stored as JSON, you'll need to write a new custom field type that can take input and reformat it as JSON, and return it in a viewable format that you prefer (noting that if that is JSON, the API will return JSON within JSON)

Ibrahim Kasim
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!
December 4, 2019

Thanks, your suggestions has resolved the issue. But I got limitation over there, when am using custom text field, character limit is set to 255. 

If I make any changes in the limit of text fields, will impact existing custom text fields too.

How do I increase the limit only to specific fields?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events