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

Ibrahim Kasim 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-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 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