Skip to content

undef values in hash2kv #25

@hozmaster

Description

@hozmaster

Json syntax allows to use null values in keys.

So basically this is syntax is valid in JSON:

{ 
    "city": "London",
    "house": null
}

However, this turns output to next if I use hash2kv:

# THIS FILE IS CONTROLLED BY PUPPET

city="London"
house="undef"

What I have in mind is that output should be like next:

# THIS FILE IS CONTROLLED BY PUPPET

city="London"
house

This is what I've tried:

      if v.nil?
         kv << "#{k}"
      else
         kv << "#{k}#{settings['key_val_separator']}#{settings['quote_char']}#{v}#{settings['quote_char']}"
     end

but no avail since v is not nil. How to change ruby code so I can achieve my task ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions