Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe add fromyaml to parse yaml strings? #2530

Open
cwrau opened this issue Jan 25, 2023 · 3 comments
Open

Maybe add fromyaml to parse yaml strings? #2530

cwrau opened this issue Jan 25, 2023 · 3 comments

Comments

@cwrau
Copy link

cwrau commented Jan 25, 2023

I saw #467 but this is not about input or output, just for parsing internally

So we could use it like this:

$ cat file.json
{
  "stuff.yaml": "apiVersion: v1\nkind: Namespace\nmetadata:\n  name: test\n"
}

$ cat file.json | jq '. | map(fromyaml)'
[
  {
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
      "name": "test"
    }
  }
]

Working json example for reference;

$ cat file.json
{
  "stuff.json": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"name\":\"test\"}}"
}

$ cat file.json | jq '. | map(fromjson)'
[
  {
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
      "name": "test"
    }
  }
]
@wader
Copy link
Member

wader commented Jan 25, 2023

Hi, jq development is a bit stalled at the moment, but fq can do this already:

$ cat file.json | fq 'map(from_yaml)'
[
  {
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
      "name": "test"
    }
  }
]

@cwrau
Copy link
Author

cwrau commented Feb 1, 2023

@wader Sorry, but we're trying to minimize our tools load and try to use tools that are common and mostly default

@wader
Copy link
Member

wader commented Feb 1, 2023

@cwrau 👍 No worries, very understandable. For now i think you probably have to use some additional tool to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants