Giter Club home page Giter Club logo

Comments (10)

Skarlso avatar Skarlso commented on July 4, 2024 1

so I figured out that the library just expects you to pass in the value you require including the right indentation level.

		{
			path: "$.data.value1.orig1",
			dst: `
data:
  value1:
    orig1: orig1.1
  value2: orig2
`,
			src: `|-
      line1
      line2
`,
			expected: `
data:
  value1:
    orig1: |-
      line1
      line2
  value2: orig2
`,
		},

Passes as a test case.

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

#292

Also reported two years ago without any resolution. :(

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

I'm attempting to see if I can fix this.

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

Reproduced the issue in path_test.go with:

		{
			path: "$.data.value1",
			dst: `
data:
  value1: orig1
  value2: orig2
`,
			src: `
line1
line2
`,
			expected: `
data:
  value1: |-
    line1
    line2
  value2: orig2
`,
		},

I'll attempt to fix the problem.

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

The AST node replace doesn't care how deep it is so it plain does a replace on the node value resulting in a YAML that doesn't work.

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

Tomorrow I'll try to fix this. I have an idea of tracking the deepness recursively for StringNodes for multi-line text. let's see..

from go-yaml.

dee0 avatar dee0 commented on July 4, 2024

Nice find @Skarlso
Can something similar be done when the new value of orig1 is an object instead of a multiline string? I ask because when I stumbled on this problem I was seeing the same problem for an object.

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

Do you have an example?

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

I tried replacing objects, but the marshalling is all over the place. There is virtually no consistency in indentation whatsoever. I can't find a pattern or anything that would make it work. :(

from go-yaml.

Skarlso avatar Skarlso commented on July 4, 2024

Okay, this now worked finally:

		{
			path: "$.data.value1.orig1",
			dst: `
data:
  value1:
    orig1: orig1.1
  value2: orig2
`,
			src: `
orig1:
  newValue:
    - value1
    - value2
`,
			expected: `
data:
  value1:
    orig1:
      orig1:
        newValue:
          - value1
          - value2
  value2: orig2
`,
		},

from go-yaml.

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.