Giter Site home page Giter Site logo

Setting value to empty string about yq HOT 3 CLOSED

mikefarah avatar mikefarah commented on May 13, 2024
Setting value to empty string

from yq.

Comments (3)

mikefarah avatar mikefarah commented on May 13, 2024 1

Ah ok cool :)

I've got a fix I should have out soon, need to check the len of arguments in the 'inQuotes' declaration

from yq.

kenjones-cisco avatar kenjones-cisco commented on May 13, 2024

After reading through the code:

func parseValue(argument string) interface{} {
	var value, err interface{}
	var inQuotes = argument[0] == '"'
	if !inQuotes {
		value, err = strconv.ParseFloat(argument, 64)
		if err == nil {
			return value
		}
		value, err = strconv.ParseBool(argument)
		if err == nil {
			return value
		}
		return argument
	}
	return argument[1 : len(argument)-1]
}

The unquoted empty string was passed in, as a result that is not understood. By explicitly passing in the quoted empty string, the result seems to work.

The workaround seems to be doing the following:

    yaml write -i project.yml metadata.pretag '""'

The result then look like this:

metadata:
  name: example
  version: 0.4.0
  pretag: ""

The desired state would result in the following:

metadata:
  name: example
  version: 0.4.0
  pretag:

from yq.

mikefarah avatar mikefarah commented on May 13, 2024

Fixed in https://github.com/mikefarah/yaml/releases/tag/1.11

from yq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.