Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio JSON Multiline String

I have a very simple json file

{
   "property" : "value"
}

The value in my application is quite long and Visual Studio forces me to write on a single line. If I try to line break like this for my mere human eyes:

{
    "property" : "value value value 
                 value value"
}

I get an error as the string is not continued on the second line. I cannot seem to use the + operator either.

Does anyone have a suggestion? Thanks.

like image 749
user3369143 Avatar asked Jun 28 '26 07:06

user3369143


1 Answers

In Visual Studio, separating a string literal onto two lines as an end-of-line character to the end of the first line. Since "control" characters must be escaped in JSON, simply add a "\" to escape the EOL and JavaScript will ignore that character. For example:

{
   "property": "This is some text I want broken \(hit enter)
    into two lines"
}

should work fine.

like image 77
tommy Avatar answered Jun 30 '26 22:06

tommy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!