내 질문: 내 애플리케이션을 테스트할 때 wget을 사용하여 JSON을 내 로컬 Tomcat으로 보냅니다.
명령을 요약하면 다음과 같습니다.
wget --header='...' --post-data='LONG_JSON' -q0 URL
확장 명령:
wget --header='Content-Type:application/json' --post-data='{"foocao": 0, "foorio": { "foo": "foofoofoo", "foofooe": "foofoo", "foon": "fooe", "fool": "foo.com", "fooa": "foofoo" }, "fooade": { "foofoofoo": "foofoo-foo-foo-foo-foofoofoo", "foo": "fooTE", "fool": "baa.com", "foofoo": "foo9-foo", "fooao": "foofoo", "fooor": "foofoo", "foofoo": "foofooia", "foofooo": "fooo", "foos": "✓ foofooade e foofooe;✓ foofooa, foofooação fooal e Polífoo e foofoo foonil;✓ foofoo e foor;✓ foofoofoo, foofoo e fooa;✓ foofooção e foofooe de fooessão;✓ Saúde;✓ fooura;✓ fooação;✓ fooitório e foofoode; foofoofoofoo e foo foofoo;✓ foo", "foo": "www.foo.com", "foodo": "aa", "foode": "foo", "foofoo": "foo", "foofoonto": "", "fooro": "1", "cep": "foofoo", "foofooo": "Bla, foola fooa"} }' -qO- http://foo/jspui/foo.jsp
교체 방법긴 JSON사용트레독쉘 스크립트 파일에서?
답변1
LONG_JSON=$(cat <<EOT
{
"foocao": 0,
"foorio":
{
"foo": "foofoofoo",
"foofooe": "foofoo",
"foon": "fooe",
"fool": "foo.com",
"fooa": "foofoo"
},
"fooade":
{
"foofoofoo": "foofoo-foo-foo-foo-foofoofoo",
"foo": "fooTE",
"fool": "baa.com",
"foofoo": "foo9-foo",
"fooao": "foofoo",
"fooor": "foofoo",
"foofoo": "foofooia",
"foofooo": "fooo",
"foos": "✓ foofooade e foofooe;✓ foofooa, foofooação fooal e Polífoo e foofoo foonil;✓ foofoo e foor;✓ foofoofoo, foofoo e fooa;✓ foofooção e foofooe de fooessão;✓ Saúde;✓ fooura;✓ fooação;✓ fooitório e foofoode; foofoofoofoo e foo foofoo;✓ foo",
"foo": "www.foo.com",
"foodo": "aa",
"foode": "foo",
"foofoo": "foo",
"foofoonto": "",
"fooro": "1",
"cep": "foofoo",
"foofooo": "Bla, foola fooa"
}
}
EOT
)
wget --header='Content-Type:application/json' --post-data="$LONG_JSON" -qO- http://foo/jspui/foo.jsp