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.

[writer]Surround string by double quote instead of simple

See original GitHub issue

I would like to be able to take a json object like this :

{
    translation:
        { 
            key: 'this_is_a_key',
            value: 'this is a value'
        }
}

and output a yml file like this :

- translation :
    key: "this_is_a_key"
    value: "this is a value"

I’ve tried several method but was only able to achieve either

- translation :
    key: this_is_a_key
    value: this is a value

or

- translation :
    key: '"this_is_a_key"'
    value: '"this is a value"'

note that in the latter this is not three quotes but a single quote followed by a double quote

Is there any way to do this with this module?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:17
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
rlidwkacommented, Dec 9, 2020

Fixed by https://github.com/nodeca/js-yaml/commit/7b256d7612a4c29cdf5dfd48a15e01c8dbbb5291 in dev branch, gonna be released later.

console.log(require('js-yaml').dump({ key: "this_is_a_key" }, { quotingType: '"', forceQuotes: true }))
// outputs:
// key: "this_is_a_key"
0reactions
ratacatcommented, Aug 29, 2019

I’d appreciate this too!

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Single' vs "Double" quotes for strings in javascript - Flexiple
A double-quoted string can have single quotes without escaping them, conversely, a single-quoted string can have double quotes within it without ...
Read more >
When should I use double or single quotes in JavaScript?
Double quotes mean a string in many other languages. When you learn a new language like Java or C, double quotes are always...
Read more >
“Double Quotes” vs 'Single Quotes' vs `Backticks` in JavaScript
“Double Quotes”. As I mentioned, both of these are used to create string literals (values) in JavaScript, and they act in exactly the...
Read more >
Python Single vs. Double Quotes - Which Should You Use ...
In Java, you must use double quotes for strings, and are only allowed to use single quotes for characters. That's not the deal...
Read more >
When to Use Double or Single Quotes in JavaScript - W3docs
There is only one difference in the usage of single and double quotes, ... First and foremost, they allow simple string concentration (“variable ......
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