It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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)

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

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you