简体   繁体   中英

Can there be a multiline key/value in json?

Is somethhing like this possible in json

let a = {
    "awe
     sdsds" : "eweq
               dfs
               ewewew"
}

can i have multiline strings as key and value

I tried and got this icon at newline for key and \n this at newline for value

This is not "JSON", it is object literal.

If you are having a literal you can use string literals and computed properties if you really want to have this kind of keys. Otherwise you'd need to use escape seq \n (see the result of JSON.stringify )

 let a = { [`awe sdsds`] : `eweq dfs ewewew` } console.log(a[`awe sdsds`]) console.log(JSON.stringify(a))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM