2017-12-06 13 views
0

現在、私はUPS Access Pointにパッケージを送信するためのオプションを追加しようとしています。文書に通知を追加する必要があることが伝えられていますUAP(013)用とADLのためのオブジェクト私は通知オブジェクトは、通常のXMLに、それは次のようになり、最大3回を許可されているドキュメントを読んで(012)UPS ShipmentRequest API JSONアクセスポイントへの出荷通知

:私は以来

<ShipmentServiceOptions> 
    <Notification> 
    <NotificationCode>012</NotificationCode> 
    some other values (here..) 
    </Notification> 
     <Notification> 
    <NotificationCode>013</NotificationCode> 
    some other values (here..) 
    </Notification> 
</ShipmentServiceOptions> 

しかし、 JSONを使用してオブジェクトの配列を作成します。

$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '012']; 
$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '013']; 

私はこの完全な配列を解読JSONとき、それは次のようになります。

{ 
"Notification": [{ 
    "NotificationCode": "013", 
    "EmailMessage": { 
     "EMailAddress": "[email protected]", 
     "UndeliverableEMailAddr": "[email protected]", 
     "FromEMailAddress ": "[email protected]", 
     "FromName": "From Email" 
    }, 
    "Locale": { 
     "Language": "ENG", 
     "Dialect": "US" 
    } 
}, { 
    "NotificationCode": "012", 
    "EmailMessage": { 
     "EMailAddress": "[email protected]", 
     "UndeliverableEMailAddr": "[email protected]", 
     "FromEMailAddress ": "From Email", 
     "FromName": "From Name" 
    }, 
    "Locale": { 
     "Language": "ENG", 
     "Dialect": "US" 
    } 
}] 

}

これは有効なJSONオブジェクトですが、何らかの理由で、私はエラーを取得しておいてください。

ADL notification code (012) and notification data (email or phone number) is required for hold for pickup at access point location shipment.

私はエラーになります周り、私は配列の値を反転:

UAP shipper notification code (013) and notification data (email or phone number) is required for UPS Access Point Delivery.

これは、1つの値だけが配列から読み込まれているように見えます。ドキュメントを読むと、複数の通知キーが必要になると信じていますが、jsonで複数の通知キーをどのように追加すればよいか分かりません

ADL notification code (012) and notification data (email or phone number) is required for hold for pickup at access point location shipment.

"ShipmentServiceOptions": [{ 
      "Notification": { 
       "NotificationCode": "013", 
       "EmailMessage": { 
        "EMailAddress": "[email protected]", 
        "UndeliverableEMailAddr": "[email protected]", 
        "FromEMailAddress ": "fromemail", 
        "FromName": "From Name" 
       }, 
       "Locale": { 
        "Language": "ENG", 
        "Dialect": "US" 
       } 
      } 
     }, { 
      "Notification": { 
       "NotificationCode": "012", 
       "EmailMessage": { 
        "EMailAddress": "[email protected]", 
        "UndeliverableEMailAddr": "[email protected]", 
        "FromEMailAddress ": "fromemail", 
        "FromName": "From Name" 
       }, 
       "Locale": { 
        "Language": "ENG", 
        "Dialect": "US" 
       } 
      } 
     }], 

それは私にこのエラーを与える:JSONオブジェクトは、...すべてのヘルプは大幅に私はJSONオブジェクトはこのように見えるように変換する際

編集

いただければ幸いです

アイテムの周りのスワッピングがエラーに

答えて

0

は変更されません。私はあなたがそれは私がXMLを入れ替え;-)

シンプルだけど、何かが修正する時間以上かかる場合、それは、シンプルなものになるだろう知っていましたWebサービスのドキュメントとドキュメント、XMLに通知メールデータが追加されたノードが呼び出されます。

:メールデータを保持している同じノードが呼び出されたJSONドキュメントで

/ShipmentConfirmRequest/Shipment/ShipmentServiceOptions/Notification/EMailMessage/

完全を期すため

/ShipmentConfirmRequest/Shipment/ShipmentServiceOptions/Notification/EMail/

、この通知オブジェクトの正しいJSONの一部である:

{ 
"Notification": [{ 
    "NotificationCode": "013", 
    "EMail": { 
     "EMailAddress": "[email protected]", 
     "UndeliverableEMailAddr": "[email protected]", 
     "FromEMailAddress ": "fromemail", 
     "FromName": "fromemail" 
    }, 
    "Locale": { 
     "Language": "ENG", 
     "Dialect": "US" 
    } 
}, { 
    "NotificationCode": "012", 
    "EMail": { 
     "EMailAddress": "[email protected]", 
     "UndeliverableEMailAddr": "[email protected]", 
     "FromEMailAddress ": "fromname", 
     "FromName": "From Name" 
    }, 
    "Locale": { 
     "Language": "ENG", 
     "Dialect": "US" 
    } 
}] 

}

関連する問題