jpsim / Yams

A Sweet and Swifty YAML parser.
https://jpsim.com/Yams
MIT License
1.09k stars 133 forks source link

Add options to force using quotes for strings encoding #344

Open maximkrouk opened 2 years ago

maximkrouk commented 2 years ago
templates:
- name: 'TCA'
  description: 'TCA template'
- name: 'MVVM'
  description: ''
  path: 'Deprecated/MVVM'

or

templates:
- name: "TCA"
  description: "TCA template"
- name: "MVVM"
  description: ""
  path: 'Deprecated/MVVM'

Instead of

templates:
- name: TCA
  description: TCA template
- name: MVVM
  description: ''
  path: Deprecated/MVVM

It's not required, just noticed that I can't control this behavior, but the thing I really would like to be customizable is to add extra indentation like:

templates:
  - name: TCA
    description: TCA template
  - name: MVVM
    description: ''
    path: Deprecated/MVVM
bzeeman commented 1 year ago

I agree with this. I would qualify. it as a bug because in certain circumstances it seems you can serialize a string (in my case obvious offenders are URL paths) and when you deserialize into a dictionary using a library like AnyCodable so that you can parse arbitrary YAML, the URL paths parse to an INT of 0. This might be a bug in AnyCodable, but it seems a simple fix is to ensure quotes strings.

bzeeman commented 1 year ago

On another note, the quoted string 'Off' gets deserialized to false.