question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: multi-line strings (e.g. description) in JSON

See original GitHub issue

When 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
shelbyscommented, Aug 6, 2015

@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(''):

"description": [
  "Line1",
  "Line2",
  "Line3"
]

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

0reactions
fehguycommented, Feb 1, 2017

Json can use \n. Yaml has native mutli-line strings. Closing, as anything else will be confusing to everyone.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found