Proposal: multi-line strings (e.g. description) in JSON
See original GitHub issueWhen maintaining Swagger files in the JSON format, it’s rather difficult to write long multi-line strings, for example in the description field. #292 provides a good example:
{
"description": "| Header 1 | Header 2 | Header 3 |\n|----------|----------|----------|\n| Data 1 | Data 2 | Data 3 |"
}
I am proposing to support array of strings in addition to raw string in certain fields like description, notes, etc.
{
"description": [
"| Header 1 | Header 2 | Header 3 |",
"|----------|----------|----------|",
"| Data 1 | Data 2 | Data 3 |"
]}
Thoughts?
/cc @shelbys @raymondfeng
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Are multi-line strings allowed in JSON?
JSON does not allow real line-breaks. You need to replace all the line breaks with \n . eg: "first line second line". can...
Read more >Storing multi-line strings in JSON with JSONLint
This quick hack helps find a way to store multi-line strings in JSON to interact with JS and Node.
Read more >Multiline — a Python package for multi-line JSON values
It can parse values spanning over multiple lines, whether it is in the form of a string or in a file. In addition...
Read more >COPY from JSON format - Amazon Redshift
Describes how to use the Amazon Redshift COPY command to load tables from data in JSON format.
Read more >Spark Read and Write JSON file into DataFrame
Sometimes you may want to read records from JSON file that scattered multiple lines, In order to read such files, use-value true to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@webron - I don’t think we’re talking about the same thing. To be clear we want to be able to do is the following, and just have the tools do
description.join('')
:Keep in mind we have a ton of Specs spread across many teams, so switching to YAML is no trivial thing. Honestly, I prefer it personally, but that doesn’t mean I can force it on everyone
Json can use
\n
. Yaml has native mutli-line strings. Closing, as anything else will be confusing to everyone.