Amazon MWS MwsJsonBuilder and format for date in json - json

I'm using Amazon MWS API. When using mock requests provided by the lib MerchantFulfillment, I see that the com.amazonservices.mws.client.MwsJsonBuilder returns an ISO8601 date not wrapped into a string. E.g.
{
"xmlns":"https:\/\/mws.amazonservices.com\/MerchantFulfillment\/2015-06-01",
"CancelShipmentResult":{
"Shipment":{
"ShipmentId":"String",
"AmazonOrderId":"String",
"SellerOrderId":"String",
"ItemList":[
{
"OrderItemId":"String",
"Quantity":1
}
],
"ShipFromAddress":{
"Name":"String",
"AddressLine1":"String",
"AddressLine2":"String",
"AddressLine3":"String",
"DistrictOrCounty":"String",
"Email":"String",
"City":"String",
"StateOrProvinceCode":"String",
"PostalCode":"String",
"CountryCode":"String",
"Phone":"String"
},
"ShipToAddress":{
"Name":"String",
"AddressLine1":"String",
"AddressLine2":"String",
"AddressLine3":"String",
"DistrictOrCounty":"String",
"Email":"String",
"City":"String",
"StateOrProvinceCode":"String",
"PostalCode":"String",
"CountryCode":"String",
"Phone":"String"
},
"PackageDimensions":{
"Length":100,
"Width":100,
"Height":100,
"Unit":"String",
"PredefinedPackageDimensions":"String"
},
"Weight":{
"Value":100,
"Unit":"String"
},
"Insurance":{
"CurrencyCode":"String",
"Amount":100
},
"ShippingService":{
"ShippingServiceName":"String",
"CarrierName":"String",
"ShippingServiceId":"String",
"ShippingServiceOfferId":"String",
"ShipDate":1969-07-21T02:56:03Z,
"EarliestEstimatedDeliveryDate":1969-07-21T02:56:03Z,
"LatestEstimatedDeliveryDate":1969-07-21T02:56:03Z,
"Rate":{
"CurrencyCode":"String",
"Amount":100
},
"ShippingServiceOptions":{
"DeliveryExperience":"String",
"DeclaredValue":{
"CurrencyCode":"String",
"Amount":100
},
"CarrierWillPickUp":true,
"LabelFormat":"String"
},
"AvailableLabelFormats":[
"String"
]
},
"Label":{
"CustomTextForLabel":"String",
"Dimensions":{
"Length":100,
"Width":100,
"Unit":"String"
},
"FileContents":{
"Contents":"String",
"FileType":"String",
"Checksum":"String"
},
"LabelFormat":"String",
"StandardIdForLabel":"String"
},
"Status":"String",
"TrackingId":"String",
"CreatedDate":1969-07-21T02:56:03Z,
"LastUpdatedDate":1969-07-21T02:56:03Z
}
},
"ResponseMetadata":{
"RequestId":"String"
}
}
So, for instance, "EarliestEstimatedDeliveryDate":1969-07-21T02:56:03Z does not look like a valid JSON. Jackson's ObjectMapper fails, clearly, complaining about the hyphen.
Am I doing something wrong?

Related

How to save data in Json format in React-admin v3?

I created JsonInput, which sends a json object to the input SimpleForm, however, a modified version of it gets into the Data Provider.
that's what is sent to the input:
json: {
"FunctionalGroup": [
{
"uaIDref": [
"2104"
],
"_Name": "Текущие параметры",
"_ID": "33"
},
{
"uaIDref": [
"2100"
],
"_Name": "Текущие параметры пониженной точности",
"_ID": "34"
},
],
"_Name": "Прибор 1",
"_ID": "32"
}
that's what came to the server:
json: {
"FunctionalGroup": [
{
"uaIDref": [
"2104"
],
"_Name": "Текущие параметры",
"_ID": "33"
},
{
"uaIDref": [
"2100"
],
"_Name": "Текущие параметры пониженной точности",
"_ID": "34"
}
],
"FunctionalGroupIds": "",
"_Name": "Прибор 1",
"_ID": "32"
},
after a response from the server with this object, this is what came in the field:
json: {
FunctionalGroup: [
{
uaIDref: [
'2104'
]
},
{
uaIDref: [
'2100'
]
}
],
FunctionalGroupIds: ''
}
what kind of magic is this?
I did some tests. When I converted the object to a string, the correct json was sent to the server, however, in the field after the server responded, the modified object was displayed again.
I found out that the conversion is related to redux.js, but what exactly happens is not understood.
Please give any comments on this.
How can I make save json?

XML response to an express API

I have a node js program, which uses the express framework. What happens, is a POST request is made using Postman to my API, and I deal with the request as required (which works great).
However, I want send back an XML response to the API call. So doing some digging online, I have found this library - https://www.npmjs.com/package/xml
I tried to adapt it to my code, so I need to convert the following json object into an XML response:
var responseJson = [{
"methodResponse": {
"params": {
"param": {
"value": {
"struct": {
"member": [
{
"name": "myValue",
"value": {
"string": "hi"
}
}
]
}
}
}
}
}
}];
And then in the response I do the following:
res.header('Content-Type', 'text/xml');
res.send(xml(responseXml, true));
However this only returns:
<methodResponse/>
and nothing else in the Postman response.
Any idea what happened to the rest and why only one line is returned? Is there a better way to do this? Thanks
You need to put square brackets around your objects.
const data = [{
"methodResponse": [{
"params": [{
"param": [{
"value": [{
"struct": [{
"member": [{
"name": "myValue",
},{
"value": [{
"string": "hi"
}]
}]
}]
}]
}]
}]
}]
}];
Which will produce:
<methodResponse><params><param><value><struct><member><name>myValue</name><value><string>hi</string></value></member></struct></value></param></params></methodResponse>

json request into string

I have the following json structure:
{
"data": [
{
"number": 123,
"animal": "mush"
},
{
"number": "123",
"animal": ""
}
],
"animal_id": 1
}
How can I save it as a string?
It varies by language, but in JavaScript (which might be likely used in your case), JSON.stringify does this job.

How to properly pass Json data to fusioncharts? -Multisiries-

First time poster, thanks for the attention.
Using web api to generate object to be consumed by fusioncharts (Multiseries). Object is produced as array of 2 classes (ChartCategories and ChartSeries) output seems fine and is retrieved in angular controller as data. yet after building up $scope.categories and $scope.dataset using data, I am unable to generate the chart with error 'No data to display'.
Partial Html template for chart:
<div id = "Div1">
<fusioncharts
width="400"
height="200"
type="mscolumn2d"
chart="{{attrs}}"
categories="{{categories}}"
dataset="{{dataset}}"
></fusioncharts>
</div>
data retrieved from web api: (copied + pasted)
[
[
{
"category": [
{
"label": "7/18/2014 9:30:01 AM"
},
{
"label": "7/18/2014 9:40:00 AM"
},
{
"label": "7/18/2014 9:50:00 AM"
}
]
},
null,
null
],
[
null,
{
"seriesname": "Free_Memory",
"renderas": "Line",
"data": [
{
"value": "6632"
},
{
"value": "5136"
},
{
"value": "6376"
}
]
},
{
"seriesname": "Page_Life_Exp",
"renderas": "Line",
"data": [
{
"value": "48859"
},
{
"value": "49458"
},
{
"value": "50057"
}
]
}
]
]
and in angular, I set the $scope.categories and $scope.dataset like so: $scope.attr is hard coded for the time being.
$scope.categories = data[0][0];
$scope.dataset = data[1][1];
What is needed in order to generate the graph?
Refer to http://jsfiddle.net/ayanonly1/yh1cvjqw/
I think following changes will make the chart live.
$scope.categories = [data[0][0]];
$scope.dataset = data[1].slice(1);

ibm worklight stored procedure

I want to parse this json object in javascript and have to obtain the values of key pass in string format.
{
"isSuccessful": true,
"resultSet": [
{
"name": "a",
"pass": "123",
"time_stamp": "2014-04-07T10:13:17.000Z"
},
{
"name": "chetan",
"pass": "123456",
"time_stamp": "2014-04-07T10:13:34.000Z"
},
{
"name": "dileep",
"pass": "456321",
"time_stamp": "2014-04-07T10:13:54.000Z"
},
{
"name": "bnc",
"pass": "654321",
"time_stamp": "2014-04-07T10:19:37.000Z"
}
]
}
If you are asking in a general sense (no links to Worklight) I would look at other answers:
How do I iterate over a JSON structure?
JavaScript loop through json array?
How do I loop through or enumerate a JavaScript object?
In Worklight, if your example is the response of a Worklight adapter, the response will be in a property called invocationResult.
See also https://www.ibm.com/developerworks/community/blogs/worklight/entry/handling_backend_responses_in_adapters?lang=en