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

Improve YAML <-> JSON Conversion Process #225

Open
buty4649 opened this issue Aug 27, 2024 · 2 comments
Open

Improve YAML <-> JSON Conversion Process #225

buty4649 opened this issue Aug 27, 2024 · 2 comments

Comments

@buty4649
Copy link
Owner

YAMLとJSONの相互変換を改善します。今もto_yaml/to_jsonを使えばできますが、意図しない出力になることがあります。

yaml -> json

$ rf -y --no-color "_.to_json(pretty_print:true)" yaml
|-
  {
    "volumes": [
      {
        "hostPath": {
          "path": "/run/containerd/containerd.sock",
          "type": "Socket"
        },
        "name": "containerd-sock"
      }
    ]
  }

json -> yaml

$ rf -j "_.to_yaml" json
"---\nvolumes:\n  - hostPath:\n      path: /run/containerd/containerd.sock\n      type: Socket\n    name: containerd-sock"

それぞれputsを使うとうまくいく

@buty4649
Copy link
Owner Author

buty4649 commented Dec 5, 2024

json -> yamlは -r オプションをつければよさそう

$ ./build/bin/rf -j -r "_.to_yaml" json
---
volumes:
  - hostPath:
      path: /run/containerd/containerd.sock
      type: Socket
    name: containerd-sock

@buty4649
Copy link
Owner Author

buty4649 commented Dec 5, 2024

-yにも-rオプションをつければ解決しそう

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

No branches or pull requests

2 participants
@buty4649 and others