2

Product クラスのオブジェクトに変換する必要がある入力として JSON 文字列を受け取ります。Product クラスは、Google クライアント ライブラリ 1.19.1 に属します。

オブジェクトマッパーを使用してJSON文字列を製品オブジェクトに変換すると、次のエラーが発生します。

エラー :

スレッド「メイン」の例外 java.lang.IllegalArgumentException: com.google.api.services.content.model.Price フィールド com.google.api.services.content.model.Product.price を java.util.LinkedHashMap に設定できません

入力json文字列を変換する方法を教えてください

同じためのコードは以下に書かれています:

org.codehaus.jackson.map.ObjectMapper をインポートします。

文字列 temp = "{\"channel\":\"online\",\"contentLanguage\":\"en\",\"offerId\":\"towel\",\"targetCountry\":\"IN \",\"状態\":\"再生品\",\"リンク\":\" https://www.sokrati.com \",\"価格\":{\"値\":\" 12\",\"currency\":\"INR\"},\"title\":\"Adventures of Tintin\",\"availability\":\"preorder\"}";

製品 product = mapper.readValue(temp, Product.class);

4

0 に答える 0