私の質問:私のアプリケーションをテストするときは、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