json2yaml 을 사용하여 yaml 문서를 json 문자열로 변환하고 있습니다. 이제 ansible_extravars
저장소 설정을 재정의하기 위해 json 문서를 한 줄 인수로 전달하고 싶습니다 .
예를 들면 :
Yaml :
container:
name: "summary"
version: "1.0.0"
some_level: "3"
another_nested:
schema: "summary"
items_string: "really just a string of words"
json doc : ( 'json2yaml'웹 페이지에서 생성됨)
{ "container": {
"name": "summary",
"version": "1.0.0",
"some_level": "3",
"another_nested": {
"schema": "summary",
"items_string": "really just a string of words"
}
}
}
다음과 같이 셸 명령을 사용했습니다. % cat json_text.txt | tr -d '[:space:]'
분명히 또한 공백을 제거합니다. container.another_nested.items_string
산출: {"container":{"name":"summary","version":"1.0.0","some_level":"3","another_nested":{"schema":"summary","items_string":"reallyjustastringofwords"}}}
JSON 문서를 한 줄로 변환하고 따옴표로 묶인 문자열에서 공백을 유지하려면 어떻게해야합니까?
tr -d '[\r\n]'
모든 공백 대신에 줄 바꿈 만 제거하면됩니다 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다