reactjs - load json object - json

I have a file data.js:
const sdc = [
{
"Type": "Buy",
"Price": 0.00226752,
"Amount": 55.95995977,
"Total": 0.12689032
},
{
"Type": "Buy",
"Price": 0.00226752,
"Amount": 146.1,
"Total": 0.33128467
},
{
"Type": "Buy",
"Price": 0.00226684,
"Amount": 150,
"Total": 0.340026
},
{
"Type": "Buy",
"Price": 0.00226684,
"Amount": 26.79415765,
"Total": 0.06073806
},
{
"Type": "Buy",
"Price": 0.00226684,
"Amount": 4.25269162,
"Total": 0.00964017
},
{
"Type": "Buy",
"Price": 0.00226659,
"Amount": 25.79415765,
"Total": 0.05846477
},
{
"Type": "Buy",
"Price": 0.00225784,
"Amount": 4.48789501,
"Total": 0.01013294
},
{
"Type": "Buy",
"Price": 0.00226659,
"Amount": 1,
"Total": 0.00226659
},
{
"Type": "Buy",
"Price": 0.00226663,
"Amount": 225,
"Total": 0.50999175
},
{
"Type": "Buy",
"Price": 0.00226662,
"Amount": 113.4736507,
"Total": 0.25720164
},
{
"Type": "Buy",
"Price": 0.00226659,
"Amount": 26.79415765,
"Total": 0.06073136
},
{
"Type": "Buy",
"Price": 0.00226651,
"Amount": 57.98798342,
"Total": 0.13143034
},
{
"Type": "Buy",
"Price": 0.00226649,
"Amount": 40.19123647,
"Total": 0.09109303
},
{
"Type": "Buy",
"Price": 0.00224958,
"Amount": 11.83690383,
"Total": 0.02662806
},
{
"Type": "Sell",
"Price": 0.00241238,
"Amount": 838,
"Total": 2.02157444
},
{
"Type": "Buy",
"Price": 0.00231078,
"Amount": 9.95795791,
"Total": 0.02301064
},
{
"Type": "Sell",
"Price": 0.0025,
"Amount": 4.1999832,
"Total": 0.01049995
},
{
"Type": "Sell",
"Price": 0.0025,
"Amount": 4.99998,
"Total": 0.01249995
},
{
"Type": "Buy",
"Price": 0.00226702,
"Amount": 3.63623022,
"Total": 0.0082434
},
{
"Type": "Buy",
"Price": 0.00226702,
"Amount": 2.14933238,
"Total": 0.00487257
},
{
"Type": "Buy",
"Price": 0.00226702,
"Amount": 15,
"Total": 0.0340053
},
{
"Type": "Buy",
"Price": 0.00226702,
"Amount": 56.80528353,
"Total": 0.12877871
},
{
"Type": "Buy",
"Price": 0.00227634,
"Amount": 76.88367619,
"Total": 0.17501338
},
{
"Type": "Sell",
"Price": 0.0000141,
"Amount": 12444,
"Total": 0.17546011
},
{
"Type": "Buy",
"Price": 0.0000141,
"Amount": 12131.09257,
"Total": 0.1710484
},
{
"Type": "Buy",
"Price": 0.00001409,
"Amount": 344.0847392,
"Total": 0.00484815
},
{
"Type": "Buy",
"Price": 0.00249461,
"Amount": 154.2853438,
"Total": 0.38488176
},
{
"Type": "Buy",
"Price": 0.00249461,
"Amount": 33.72938801,
"Total": 0.08414166
},
{
"Type": "Buy",
"Price": 0.00246953,
"Amount": 340.8737595,
"Total": 0.84179797
},
{
"Type": "Buy",
"Price": 0.00246953,
"Amount": 90.36231511,
"Total": 0.22315244
},
{
"Type": "Buy",
"Price": 0.00246952,
"Amount": 55.17093479,
"Total": 0.13624572
},
{
"Type": "Buy",
"Price": 0.00246764,
"Amount": 5.75660177,
"Total": 0.01420522
},
{
"Type": "Buy",
"Price": 0.00245929,
"Amount": 4.1587629,
"Total": 0.0102276
},
{
"Type": "Sell",
"Price": 0.00252904,
"Amount": 37.42985716,
"Total": 0.0946616
},
{
"Type": "Sell",
"Price": 0.00252904,
"Amount": 0.59310808,
"Total": 0.00149999
},
{
"Type": "Sell",
"Price": 0.00252904,
"Amount": 1.97703476,
"Total": 0.00499999
},
{
"Type": "Sell",
"Price": 0.00252902,
"Amount": 446.0229574,
"Total": 1.12800097
},
{
"Type": "Sell",
"Price": 0.00252903,
"Amount": 1.97704258,
"Total": 0.00499999
},
{
"Type": "Sell",
"Price": 0.00259459,
"Amount": 38.54173491,
"Total": 0.09999999
},
{
"Type": "Sell",
"Price": 0.00259483,
"Amount": 105.9381622,
"Total": 0.27489152
},
{
"Type": "Sell",
"Price": 0.00259484,
"Amount": 0.03853803,
"Total": 0.0001
},
{
"Type": "Sell",
"Price": 0.00259484,
"Amount": 0.03853803,
"Total": 0.0001
},
{
"Type": "Sell",
"Price": 0.00259485,
"Amount": 1.91102375,
"Total": 0.00495881
},
{
"Type": "Sell",
"Price": 0.00259459,
"Amount": 2,
"Total": 0.00518918
},
{
"Type": "Sell",
"Price": 0.00259464,
"Amount": 1.90549392,
"Total": 0.00494407
},
{
"Type": "Sell",
"Price": 0.00259465,
"Amount": 28.65568722,
"Total": 0.07435147
},
{
"Type": "Buy",
"Price": 0.01740491,
"Amount": 0.20683711,
"Total": 0.00359998
},
{
"Type": "Buy",
"Price": 0.00238916,
"Amount": 79.70696671,
"Total": 0.19043269
},
{
"Type": "Buy",
"Price": 0.00237524,
"Amount": 37.90636505,
"Total": 0.09003671
},
{
"Type": "Buy",
"Price": 0.00237524,
"Amount": 2.00494017,
"Total": 0.00476221
},
{
"Type": "Buy",
"Price": 0.00237524,
"Amount": 18.57724489,
"Total": 0.04412541
},
{
"Type": "Sell",
"Price": 0.00585,
"Amount": 56.99961222,
"Total": 0.33344773
},
{
"Type": "Sell",
"Price": 0.00585,
"Amount": 0.00007739,
"Total": 4.5e-7
},
{
"Type": "Sell",
"Price": 0.00585,
"Amount": 0.00031039,
"Total": 0.00000181
},
{
"Type": "Buy",
"Price": 8.6e-7,
"Amount": 2070,
"Total": 0.0017802
},
{
"Type": "Buy",
"Price": 0.00187861,
"Amount": 65.81153335,
"Total": 0.1236342
},
{
"Type": "Buy",
"Price": 0.00187858,
"Amount": 15.66747734,
"Total": 0.0294326
},
{
"Type": "Buy",
"Price": 0.00187857,
"Amount": 7.94470487,
"Total": 0.01492468
},
{
"Type": "Buy",
"Price": 0.00187853,
"Amount": 0.78814015,
"Total": 0.00148054
},
{
"Type": "Buy",
"Price": 0.00187852,
"Amount": 0.78814429,
"Total": 0.00148054
},
{
"Type": "Sell",
"Price": 0.00054142,
"Amount": 0.9975,
"Total": 0.00054006
},
{
"Type": "Buy",
"Price": 8.6e-7,
"Amount": 811.9167491,
"Total": 0.00069824
},
{
"Type": "Buy",
"Price": 8.6e-7,
"Amount": 338.0832509,
"Total": 0.00029075
},
{
"Type": "Buy",
"Price": 0.00238719,
"Amount": 72,
"Total": 0.17187768
},
{
"Type": "Buy",
"Price": 0.00236363,
"Amount": 4,
"Total": 0.00945452
},
{
"Type": "Sell",
"Price": 0.00023501,
"Amount": 41.1642077,
"Total": 0.009674
},
{
"Type": "Sell",
"Price": 0.00023501,
"Amount": 2.7697923,
"Total": 0.00065092
},
{
"Type": "Buy",
"Price": 0.00000105,
"Amount": 1270,
"Total": 0.0013335
},
{
"Type": "Buy",
"Price": 0.00281001,
"Amount": 360,
"Total": 1.0116036
},
{
"Type": "Buy",
"Price": 0.00280001,
"Amount": 3.33990832,
"Total": 0.00935177
},
{
"Type": "Sell",
"Price": 0.0038,
"Amount": 208,
"Total": 0.7904
},
{
"Type": "Sell",
"Price": 0.00356245,
"Amount": 1,
"Total": 0.00356245
},
{
"Type": "Sell",
"Price": 0.00370002,
"Amount": 0.02702689,
"Total": 0.0001
},
{
"Type": "Sell",
"Price": 0.00370002,
"Amount": 15.4008193,
"Total": 0.05698333
},
{
"Type": "Sell",
"Price": 0.00370002,
"Amount": 3.09119995,
"Total": 0.0114375
},
{
"Type": "Sell",
"Price": 0.02315202,
"Amount": 6.98549994,
"Total": 0.16172843
},
{
"Type": "Sell",
"Price": 0.02315202,
"Amount": 6e-8,
"Total": 0
},
{
"Type": "Buy",
"Price": 0.00023492,
"Amount": 40,
"Total": 0.0093968
},
{
"Type": "Sell",
"Price": 0.00004456,
"Amount": 40.3006157,
"Total": 0.00179579
},
{
"Type": "Sell",
"Price": 0.00004461,
"Amount": 112.0824927,
"Total": 0.00499999
},
{
"Type": "Sell",
"Price": 0.00004462,
"Amount": 33.61721201,
"Total": 0.00149999
},
{
"Type": "Sell",
"Price": 0.00004463,
"Amount": 33.60967959,
"Total": 0.0015
},
{
"Type": "Buy",
"Price": 0.0002817,
"Amount": 4,
"Total": 0.0011268
},
{
"Type": "Buy",
"Price": 0.00003965,
"Amount": 55.13060038,
"Total": 0.00218592
},
{
"Type": "Buy",
"Price": 0.00003965,
"Amount": 104.8693996,
"Total": 0.00415807
},
{
"Type": "Sell",
"Price": 0.00004129,
"Amount": 149.625,
"Total": 0.00617801
},
{
"Type": "Buy",
"Price": 0.02215591,
"Amount": 3,
"Total": 0.06646773
},
{
"Type": "Buy",
"Price": 0.00004073,
"Amount": 113.3174137,
"Total": 0.00461541
},
{
"Type": "Buy",
"Price": 0.00004072,
"Amount": 36.68258634,
"Total": 0.00149371
},
{
"Type": "Buy",
"Price": 0.0000525,
"Amount": 60,
"Total": 0.00315
},
{
"Type": "Buy",
"Price": 0.01877317,
"Amount": 4,
"Total": 0.07509268
},
{
"Type": "Buy",
"Price": 0.00199501,
"Amount": 43.10755334,
"Total": 0.08599999
},
{
"Type": "Buy",
"Price": 0.00350201,
"Amount": 53.48162609,
"Total": 0.18729318
},
{
"Type": "Buy",
"Price": 0.00350201,
"Amount": 132.1260678,
"Total": 0.46270681
},
{
"Type": "Sell",
"Price": 0.02304826,
"Amount": 17.03647964,
"Total": 0.39266121
},
{
"Type": "Sell",
"Price": 0.02312381,
"Amount": 3.52,
"Total": 0.08139581
},
{
"Type": "Sell",
"Price": 0.02324002,
"Amount": 3.39252036,
"Total": 0.07884224
},
{
"Type": "Buy",
"Price": 0.02459958,
"Amount": 7,
"Total": 0.17219706
},
{
"Type": "Buy",
"Price": 0.01378499,
"Amount": 9,
"Total": 0.12406491
},
{
"Type": "Buy",
"Price": 0.00581178,
"Amount": 1,
"Total": 0.00581178
},
{
"Type": "Buy",
"Price": 0.01498881,
"Amount": 7,
"Total": 0.10492167
},
{
"Type": "Sell",
"Price": 0.00001717,
"Amount": 176.6891735,
"Total": 0.00303375
},
{
"Type": "Sell",
"Price": 0.00001718,
"Amount": 87.31082654,
"Total": 0.00149999
},
{
"Type": "Buy",
"Price": 0.00001464,
"Amount": 182.8870467,
"Total": 0.00267746
},
{
"Type": "Buy",
"Price": 0.00001464,
"Amount": 32.11295335,
"Total": 0.00047013
},
{
"Type": "Buy",
"Price": 0.00596086,
"Amount": 26,
"Total": 0.15498236
},
{
"Type": "Buy",
"Price": 0.000017,
"Amount": 50,
"Total": 0.00085
},
{
"Type": "Buy",
"Price": 0.0005388,
"Amount": 1,
"Total": 0.0005388
},
{
"Type": "Buy",
"Price": 0.00935588,
"Amount": 0.00060288,
"Total": 0.00000564
},
{
"Type": "Buy",
"Price": 0.00935588,
"Amount": 0.99939712,
"Total": 0.00935023
},
{
"Type": "Buy",
"Price": 0.01475001,
"Amount": 1,
"Total": 0.01475001
},
{
"Type": "Buy",
"Price": 0.00555,
"Amount": 21.28693846,
"Total": 0.1181425
},
{
"Type": "Buy",
"Price": 0.00553,
"Amount": 9.26025155,
"Total": 0.05120919
}
]
I'm trying to load it with:
import React, {Component} from 'react';
import Header from './header/header';
import Body from './body/body';
import sdc from './data';
export default class App extends Component {
constructor(props) {
super();
// Set the initial grid in
this.state = {
title: "Singularity is nigh!!!",
sdc: sdc
};
}
render() {
return (
// Add your component markup and other subcomponent references here.
<div>
<Header title={this.state.title} />
<p>{this.state.sdc}</p>
<Body />
</div>
);
}
}
I have got an error saying that:
Uncaught Invariant Violation: Objects are not valid as a React child
(found: object with keys {}). If you meant to render a collection of
children, use an array instead or wrap the object using
createFragment(object) from the React add-ons. Check the render method
of App.
Please advise. I'm trying to do some calculations on the values but first I need to load it and be able to extract values from the object.
Thanks
Edit:
Error:
/scripts/App.js
Module build failed: SyntaxError: Unexpected token (32:30)
30 |
31 | render() {
> 32 | const renderedData = {this._renderData()}
| ^
33 |
34 |
35 | return (
BabelLoaderError: SyntaxError: Unexpected token (32:30)
30 |
31 | render() {
> 32 | const renderedData = {this._renderData()}
| ^
33 |
34 |
35 | return (
EDIT 2:
import React, {Component} from 'react';
import Header from './header/header';
import Body from './body/body';
import sdc from './data';
export default class App extends Component {
constructor(props) {
super();
// Set the initial grid in
this.state = {
title: "Singularity is nigh!!!",
sdc: sdc
};
}
_renderData(){
const data = this.state.sdc
return Object.keys(data).map(function(key,index){
return ( <div key={datum.id}>
<p>{datum.Type}</p>
<p>{datum.Price}</p>
//other properties
</div> )
})
}
render() {
const renderedData = this._renderData()
return (
// Add your component markup and other subcomponent references here.
<div>
<p>{renderedData}</p>
</div>
);
}
}

Ideally you should not render objects(or array) this way. The correct way is to iterate over the array(or object) and then printing the data. Somewhat like this:-
_renderData(){
const data = this.state.sdc
return Object.keys(data).map(function(key,index){
const datum = data[key]
return ( <div key={datum.id}>
<p>{datum.Type}</p>
<p>{datum.Price}</p>
//other properties
</div> )
})
}
render(){
const renderedData = this._renderData()
return (
// Add your component markup and other subcomponent references here.
<div>
<Header title={this.state.title} />
<p>{renderedData}</p>
<Body />
</div>
);
}

React wants to render a component. You are passing a (presumably) JSON object.
If you wanted to see the JSON rendered you could modify your output line to
<p>{JSON.stringify(this.state.sdc)}</p>

You data.js is wrong:
const sdc = [
You need to have export statement, so this should be:
export default [
Otherwise, importing sdc will just give you an empty document.

Related

Flutter dynamic data from api to make Widgets

In my case the json will be different every time and i have to make widget like "inputtype": "dropdown", "inputtype": "radiobutton" but if i craete model it don't go as i wants it to.
{
"fields": [
{
"id": 31,
"name": "make",
"isrequired": "required",
"valuetype": "text",
"priority": 1,
"inputtype": "dropdown",
"max_min": [],
"rangeable": "false",
"choices": [
{
"id": 46,
"name": "Samsung",
"categoryextrafield_id": 31,
"created_at": "2021-12-29T01:30:47.000000Z",
"updated_at": "2021-12-29T01:30:47.000000Z",
"priority": 10
},
{
"id": 47,
"name": "Dell",
"categoryextrafield_id": 31,
"created_at": "2021-12-29T01:30:52.000000Z",
"updated_at": "2021-12-29T01:30:52.000000Z",
"priority": 20
},
{
"id": 48,
"name": "IBM",
"categoryextrafield_id": 31,
"created_at": "2021-12-29T01:31:09.000000Z",
"updated_at": "2021-12-29T01:31:09.000000Z",
"priority": 30
},
{
"id": 49,
"name": "Acer",
"categoryextrafield_id": 31,
"created_at": "2021-12-29T01:31:24.000000Z",
"updated_at": "2021-12-29T01:31:24.000000Z",
"priority": 40
}
],
"available": []
},
{
"id": 32,
"name": "model",
"isrequired": "required",
"valuetype": "text",
"priority": 2,
"inputtype": "textfield",
"max_min": [],
"rangeable": "false",
"choices": [],
"available": [
{
"model": "a51"
},
{
"model": "y9s"
},
{
"model": "a31"
},
{
"model": "yS10"
},
{
"model": "Y10S"
},
{
"model": "A551"
},
{
"model": "node8"
},
{
"model": "s9"
},
{
"model": null
},
{
"model": "2021"
},
{
"model": "2020"
},
{
"model": "2010"
},
{
"model": "Civic"
},
{
"model": "2019"
},
{
"model": "Daewooy9"
},
{
"model": "corei5"
},
{
"model": "corei9"
},
{
"model": "corei3"
},
{
"model": "corei11"
}
]
},
{
"id": 29,
"name": "features",
"isrequired": "required",
"valuetype": "text",
"priority": 3,
"inputtype": "checkbox",
"max_min": [],
"rangeable": "false",
"choices": [
{
"id": 41,
"name": "Bluetooth",
"categoryextrafield_id": 29,
"created_at": "2021-12-29T01:19:00.000000Z",
"updated_at": "2021-12-29T01:19:00.000000Z",
"priority": 1
},
{
"id": 42,
"name": "Fingerprint",
"categoryextrafield_id": 29,
"created_at": "2021-12-29T01:19:10.000000Z",
"updated_at": "2021-12-29T01:19:10.000000Z",
"priority": 10
},
{
"id": 43,
"name": "LedDisplay",
"categoryextrafield_id": 29,
"created_at": "2021-12-29T01:19:35.000000Z",
"updated_at": "2021-12-29T01:19:35.000000Z",
"priority": 15
}
],
"available": []
},
{
"id": 30,
"name": "condition",
"isrequired": "required",
"valuetype": "text",
"priority": 4,
"inputtype": "radiobutton",
"max_min": [],
"rangeable": "false",
"choices": [
{
"id": 44,
"name": "Used",
"categoryextrafield_id": 30,
"created_at": "2021-12-29T01:20:31.000000Z",
"updated_at": "2021-12-29T01:20:31.000000Z",
"priority": 10
},
{
"id": 45,
"name": "New",
"categoryextrafield_id": 30,
"created_at": "2021-12-29T01:20:38.000000Z",
"updated_at": "2021-12-29T01:20:38.000000Z",
"priority": 20
}
],
"available": []
}
]
}

How to filter keys in record_path in pandas json_normalize method?

I have a large json/dict:
{
"vegetarian": false,
"vegan": false,
"glutenFree": false,
"dairyFree": false,
"veryHealthy": false,
"cheap": false,
"veryPopular": false,
"sustainable": false,
"weightWatcherSmartPoints": 14,
"gaps": "no",
"lowFodmap": false,
"aggregateLikes": 1,
"spoonacularScore": 57.0,
"healthScore": 21.0,
"creditsText": "BBC Good Food",
"sourceName": "BBC Good Food",
"pricePerServing": 231.2,
"id": 1089577,
"title": "Hungarian Goulash Stew",
"readyInMinutes": 120,
"servings": 4,
"sourceUrl": "https://www.bbcgoodfood.com/recipes/1107653/hungarian-goulash-stew",
"image": "https://spoonacular.com/recipeImages/1089577-312x231.jpg",
"imageType": "jpg",
"nutrition": {
"nutrients": [
{
"name": "Calories",
"title": "Calories",
"amount": 323.18,
"unit": "kcal",
"percentOfDailyNeeds": 16.16
},
{
"name": "Fat",
"title": "Fat",
"amount": 15.14,
"unit": "g",
"percentOfDailyNeeds": 23.3
},
{
"name": "Saturated Fat",
"title": "Saturated Fat",
"amount": 4.43,
"unit": "g",
"percentOfDailyNeeds": 27.69
},
{
"name": "Carbohydrates",
"title": "Carbohydrates",
"amount": 38.95,
"unit": "g",
"percentOfDailyNeeds": 12.98
},
{
"name": "Net Carbohydrates",
"title": "Net Carbohydrates",
"amount": 34.64,
"unit": "g",
"percentOfDailyNeeds": 12.6
},
{
"name": "Sugar",
"title": "Sugar",
"amount": 11.27,
"unit": "g",
"percentOfDailyNeeds": 12.52
},
{
"name": "Cholesterol",
"title": "Cholesterol",
"amount": 102.67,
"unit": "mg",
"percentOfDailyNeeds": 34.22
},
{
"name": "Sodium",
"title": "Sodium",
"amount": 1864.24,
"unit": "mg",
"percentOfDailyNeeds": 81.05
},
{
"name": "Protein",
"title": "Protein",
"amount": 10.3,
"unit": "g",
"percentOfDailyNeeds": 20.6
},
{
"name": "Vitamin A",
"title": "Vitamin A",
"amount": 3866.5,
"unit": "IU",
"percentOfDailyNeeds": 77.33
},
{
"name": "Vitamin E",
"title": "Vitamin E",
"amount": 3.49,
"unit": "mg",
"percentOfDailyNeeds": 23.3
},
{
"name": "Selenium",
"title": "Selenium",
"amount": 13.41,
"unit": "µg",
"percentOfDailyNeeds": 19.16
},
{
"name": "Manganese",
"title": "Manganese",
"amount": 0.38,
"unit": "mg",
"percentOfDailyNeeds": 18.83
},
{
"name": "Iron",
"title": "Iron",
"amount": 3.19,
"unit": "mg",
"percentOfDailyNeeds": 17.74
},
{
"name": "Vitamin B2",
"title": "Vitamin B2",
"amount": 0.3,
"unit": "mg",
"percentOfDailyNeeds": 17.54
},
{
"name": "Fiber",
"title": "Fiber",
"amount": 4.31,
"unit": "g",
"percentOfDailyNeeds": 17.22
},
{
"name": "Folate",
"title": "Folate",
"amount": 61.04,
"unit": "µg",
"percentOfDailyNeeds": 15.26
},
{
"name": "Vitamin B6",
"title": "Vitamin B6",
"amount": 0.3,
"unit": "mg",
"percentOfDailyNeeds": 14.9
},
{
"name": "Vitamin B1",
"title": "Vitamin B1",
"amount": 0.21,
"unit": "mg",
"percentOfDailyNeeds": 13.72
},
{
"name": "Vitamin K",
"title": "Vitamin K",
"amount": 13.78,
"unit": "µg",
"percentOfDailyNeeds": 13.13
},
{
"name": "Potassium",
"title": "Potassium",
"amount": 407.99,
"unit": "mg",
"percentOfDailyNeeds": 11.66
},
{
"name": "Vitamin C",
"title": "Vitamin C",
"amount": 9.53,
"unit": "mg",
"percentOfDailyNeeds": 11.56
},
{
"name": "Phosphorus",
"title": "Phosphorus",
"amount": 111.88,
"unit": "mg",
"percentOfDailyNeeds": 11.19
},
{
"name": "Vitamin B3",
"title": "Vitamin B3",
"amount": 2.01,
"unit": "mg",
"percentOfDailyNeeds": 10.05
},
{
"name": "Copper",
"title": "Copper",
"amount": 0.15,
"unit": "mg",
"percentOfDailyNeeds": 7.53
},
{
"name": "Magnesium",
"title": "Magnesium",
"amount": 29.73,
"unit": "mg",
"percentOfDailyNeeds": 7.43
},
{
"name": "Vitamin B5",
"title": "Vitamin B5",
"amount": 0.69,
"unit": "mg",
"percentOfDailyNeeds": 6.95
},
{
"name": "Zinc",
"title": "Zinc",
"amount": 0.89,
"unit": "mg",
"percentOfDailyNeeds": 5.93
},
{
"name": "Calcium",
"title": "Calcium",
"amount": 58.6,
"unit": "mg",
"percentOfDailyNeeds": 5.86
},
{
"name": "Vitamin B12",
"title": "Vitamin B12",
"amount": 0.2,
"unit": "µg",
"percentOfDailyNeeds": 3.3
},
{
"name": "Vitamin D",
"title": "Vitamin D",
"amount": 0.46,
"unit": "µg",
"percentOfDailyNeeds": 3.06
}
]
}
I would like to keep the id, readyInMinutes and title keys + nutrition, the issue is that I need the nutrition to be parsed (because it's a list of dicts).
I am trying panda's pd.json_normalize function to do this:
keys = ['id', 'title', 'readyInMinutes']
pd.json_normalize(results[0], meta = keys, record_path=['nutrition',['nutrients']], record_prefix='nutrients.')
But if I need to filter which keys I want inside the record_path? For example only title and amount?
Please instruct how can I configure it.
To parse JSON data you can use JMESPath library.
JMESPath search syntax:
search(<jmespath expr>, <JSON document>)
In your case the JMESPath expression will be this:
{id: id, readyInMinutes:readyInMinutes, title: title, nutrition: {nutrients: nutrition.nutrients[*].{title: title, amount: amount}}}
Output:
{
"id": 1089577,
"readyInMinutes": 120,
"title": "Hungarian Goulash Stew",
"nutrition": {
"nutrients": [
{
"title": "Calories",
"amount": 323.18
},
{
"title": "Fat",
"amount": 15.14
},
{
"title": "Saturated Fat",
"amount": 4.43
},
{
"title": "Carbohydrates",
"amount": 38.95
},
{
"title": "Net Carbohydrates",
"amount": 34.64
},
{
"title": "Sugar",
"amount": 11.27
},
{
"title": "Cholesterol",
"amount": 102.67
},
{
"title": "Sodium",
"amount": 1864.24
},
{
"title": "Protein",
"amount": 10.3
},
{
"title": "Vitamin A",
"amount": 3866.5
},
{
"title": "Vitamin E",
"amount": 3.49
},
{
"title": "Selenium",
"amount": 13.41
},
{
"title": "Manganese",
"amount": 0.38
},
{
"title": "Iron",
"amount": 3.19
},
{
"title": "Vitamin B2",
"amount": 0.3
},
{
"title": "Fiber",
"amount": 4.31
},
{
"title": "Folate",
"amount": 61.04
},
{
"title": "Vitamin B6",
"amount": 0.3
},
{
"title": "Vitamin B1",
"amount": 0.21
},
{
"title": "Vitamin K",
"amount": 13.78
},
{
"title": "Potassium",
"amount": 407.99
},
{
"title": "Vitamin C",
"amount": 9.53
},
{
"title": "Phosphorus",
"amount": 111.88
},
{
"title": "Vitamin B3",
"amount": 2.01
},
{
"title": "Copper",
"amount": 0.15
},
{
"title": "Magnesium",
"amount": 29.73
},
{
"title": "Vitamin B5",
"amount": 0.69
},
{
"title": "Zinc",
"amount": 0.89
},
{
"title": "Calcium",
"amount": 58.6
},
{
"title": "Vitamin B12",
"amount": 0.2
},
{
"title": "Vitamin D",
"amount": 0.46
}
]
}
}

Extract Specific Values in a JSON String using XSLT

I need help in getting the specific keys and its dynamic values stored in JSON string in an XML element.
Below is an example of the JSON data:
<data attribute-id="item">
[
{
"item_name": "item1",
"quantity": 1,
"key": "subtotal",
"price": {
"currency": "CAD",
"amount": 123.75,
"label": "320.088,75 CAD",
"base": {
"amount": 34.75,
"currency": "USD",
"label": "US$90.75"
}
},
"total": {
"currency": "CAD",
"amount": 123.75,
"label": "320.088,75 CAD",
"base": {
"amount": 90.75,
"currency": "USD",
"label": "US$90.75"
}
},
"included": [
{
"key": "item_price",
"total": {
"currency": "CAD",
"amount": 123,
"label": "376.575,00 CAD",
"base": {
"amount": 106.76,
"currency": "USD",
"label": "US$106.76"
}
},
"price": {
"currency": "CAD",
"amount": 123,
"label": "376.575,00 CAD",
"base": {
"amount": 106.76,
"currency": "USD",
"label": "US$106.76"
}
}
},
{
"key": "rounding",
"total": {
"currency": "CAD",
"amount": 0,
"label": "0,00 CAD",
"base": {
"amount": 0,
"currency": "USD",
"label": "US$0.00"
}
},
"price": {
"currency": "CAD",
"amount": 0,
"label": "0,00 CAD",
"base": {
"amount": 0,
"currency": "USD",
"label": "US$0.00"
}
}
},
{
"key": "item_discount",
"total": {
"currency": "CAD",
"amount": -56486.25,
"label": "-56.486,25 CAD",
"base": {
"amount": -16.01,
"currency": "USD",
"label": "-US$16.01"
}
},
"price": {
"currency": "CAD",
"amount": -56486.25,
"label": "-56.486,25 CAD",
"base": {
"amount": -16.01,
"currency": "USD",
"label": "-US$16.01"
}
}
}
]
},
{
"item_name": "item2",
"quantity": 2,
"key": "subtotal",
"price": {
"currency": "CAD",
"amount": 14343.75,
"label": "320.088,75 CAD",
"base": {
"amount": 90.75,
"currency": "USD",
"label": "US$90.75"
}
},
"total": {
"currency": "CAD",
"amount": 3431.5,
"label": "640.177,50 CAD",
"base": {
"amount": 181.5,
"currency": "USD",
"label": "US$181.50"
}
},
"included": [
{
"key": "item_price",
"total": {
"currency": "CAD",
"amount": 753150,
"label": "753.150,00 CAD",
"base": {
"amount": 213.52,
"currency": "USD",
"label": "US$213.52"
}
},
"price": {
"currency": "CAD",
"amount": 376575,
"label": "376.575,00 CAD",
"base": {
"amount": 106.76,
"currency": "USD",
"label": "US$106.76"
}
}
},
{
"key": "rounding",
"total": {
"currency": "CAD",
"amount": 0,
"label": "0,00 CAD",
"base": {
"amount": 0,
"currency": "USD",
"label": "US$0.00"
}
},
"price": {
"currency": "CAD",
"amount": 0,
"label": "0,00 CAD",
"base": {
"amount": 0,
"currency": "USD",
"label": "US$0.00"
}
}
},
{
"key": "item_discount",
"total": {
"currency": "CAD",
"amount": -112972.5,
"label": "-112.972,50 CAD",
"base": {
"amount": -32.02,
"currency": "USD",
"label": "-US$32.02"
}
},
"price": {
"currency": "CAD",
"amount": -56486.25,
"label": "-56.486,25 CAD",
"base": {
"amount": -16.01,
"currency": "USD",
"label": "-US$16.01"
}
}
}
]
}
]
</data>
My Expected output is to get key "item_name" and its dynamic value and key "amount" and its dynamic value (key->discount (base array)). Below is the expected output from the given JSON string:
"item_name": "item1","base": {
"amount": -16.01,
"currency": "USD",
"label": "-US$16.01"
},
"item_name": "item2","base": {
"amount": -32.02,
"currency": "USD",
"label": "-US$32.02"
}
Any help is greatly appreciated!

How to group flight segments/legs in Bargain Finder Max?

I am trying to search for flights between two places in Sabre using BargainFindermax API. The API provides me with a list of all flights. However, there is no direct relation to which of the flights are linked.
For example, I searched for flights between BLR > LCY. The response I got included flights for AMS > LCY, BLR > DEL, BLR > DEL, DEL > AMS, AMS > LCY.
From this, I can construct the following route BLR > DEL > AMS > LCY. But there are two flights for BLR > DEL and AMS > LCY.
How can I identify which of these flights are related?
Here is the complete JSON response,
{
"groupedItineraryResponse": {
"version": "5.2.0",
"messages": [
{
"severity": "Info",
"type": "WORKERTHREAD",
"code": "TRANSACTIONID",
"text": "2074398531853061390"
},
{
"severity": "Info",
"type": "SERVER",
"code": "ASE032LPSCIL9UM.IDM.SGDCCERT.SABRE.COM",
"text": "27036"
},
{
"severity": "Info",
"type": "DRE",
"code": "RULEID",
"text": "17203"
},
{
"severity": "Info",
"type": "DEFAULT",
"code": "RULEID",
"text": "25238"
}
],
"statistics": {
"itineraryCount": 2
},
"scheduleDescs": [
{
"id": 1,
"frequency": "*MTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 257,
"departure": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "08:45:00+02:00"
},
"arrival": {
"airport": "LCY",
"city": "LON",
"country": "GB",
"time": "08:50:00+01:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 985,
"operating": "KL",
"operatingFlightNumber": 985,
"codeShared": "/KLM CITYHOPPER",
"equipment": {
"code": "E90",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 2,
"trafficRestriction": "G",
"frequency": "SMTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 1058,
"departure": {
"airport": "BLR",
"city": "BLR",
"country": "IN",
"time": "19:50:00+05:30"
},
"arrival": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "22:50:00+05:30",
"terminal": "3"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3798,
"operating": "9W",
"operatingFlightNumber": 812,
"disclosure": "9W",
"equipment": {
"code": "73H",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 3,
"trafficRestriction": "G",
"frequency": "SMTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 1058,
"departure": {
"airport": "BLR",
"city": "BLR",
"country": "IN",
"time": "18:55:00+05:30"
},
"arrival": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "22:00:00+05:30",
"terminal": "3"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3703,
"operating": "9W",
"operatingFlightNumber": 833,
"disclosure": "9W",
"equipment": {
"code": "738",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 4,
"frequency": "*M**T**",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 3961,
"departure": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "02:10:00+05:30",
"terminal": "3"
},
"arrival": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "07:40:00+02:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3817,
"operating": "9W",
"operatingFlightNumber": 234,
"disclosure": "9W",
"equipment": {
"code": "333",
"typeForFirstLeg": "W",
"typeForLastLeg": "W"
}
}
},
{
"id": 5,
"frequency": "*MTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 257,
"departure": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "09:25:00+02:00"
},
"arrival": {
"airport": "LCY",
"city": "LON",
"country": "GB",
"time": "09:30:00+01:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 987,
"operating": "KL",
"operatingFlightNumber": 987,
"codeShared": "/KLM CITYHOPPER",
"equipment": {
"code": "E90",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
}
],
"taxDescs": [
{
"id": 1,
"code": "YRI",
"amount": 160,
"currency": "USD",
"description": "SERVICE FEE - CARRIER-IMPOSED MISC",
"publishedAmount": 160,
"publishedCurrency": "USD",
"station": "DEL"
},
{
"id": 2,
"code": "YQI",
"amount": 13.3,
"currency": "USD",
"description": "SERVICE FEE - INSURANCE",
"publishedAmount": 925,
"publishedCurrency": "INR",
"station": "BLR"
},
{
"id": 3,
"code": "WO",
"amount": 3.8,
"currency": "USD",
"description": "PASSENGER SERVICE FEE",
"publishedAmount": 3.8,
"publishedCurrency": "USD",
"station": "BLR",
"country": "IN"
},
{
"id": 4,
"code": "K38",
"amount": 11.5,
"currency": "USD",
"description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
"publishedAmount": 799,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
},
{
"id": 5,
"code": "CJ",
"amount": 7.4,
"currency": "USD",
"description": "SECURITY SERVICE CHARGE",
"publishedAmount": 6.5,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 6,
"code": "RN",
"amount": 7.3,
"currency": "USD",
"description": "PASSENGER SERVICE CHARGE",
"publishedAmount": 6.4,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 7,
"code": "IN",
"amount": 5.2,
"currency": "USD",
"description": "USER DEVELOPMENT FEE DEPARTURES",
"publishedAmount": 362,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
}
],
"taxSummaryDescs": [
{
"id": 1,
"code": "YRI",
"amount": 160,
"currency": "USD",
"description": "SERVICE FEE - CARRIER-IMPOSED MISC",
"publishedAmount": 160,
"publishedCurrency": "USD",
"station": "DEL"
},
{
"id": 2,
"code": "YQI",
"amount": 13.3,
"currency": "USD",
"description": "SERVICE FEE - INSURANCE",
"publishedAmount": 925,
"publishedCurrency": "INR",
"station": "BLR"
},
{
"id": 3,
"code": "WO",
"amount": 3.8,
"currency": "USD",
"description": "PASSENGER SERVICE FEE",
"publishedAmount": 3.8,
"publishedCurrency": "USD",
"station": "BLR",
"country": "IN"
},
{
"id": 4,
"code": "K38",
"amount": 11.5,
"currency": "USD",
"description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
"publishedAmount": 0.05,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
},
{
"id": 5,
"code": "CJ",
"amount": 7.4,
"currency": "USD",
"description": "SECURITY SERVICE CHARGE",
"publishedAmount": 6.5,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 6,
"code": "RN",
"amount": 7.3,
"currency": "USD",
"description": "PASSENGER SERVICE CHARGE",
"publishedAmount": 6.4,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 7,
"code": "IN",
"amount": 5.2,
"currency": "USD",
"description": "USER DEVELOPMENT FEE DEPARTURES",
"publishedAmount": 362,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
}
],
"fareComponentDescs": [
{
"id": 1,
"governingCarrier": "KL",
"fareAmount": 24.65,
"fareCurrency": "INR",
"fareBasisCode": "XPLWIA",
"farePassengerType": "ADT",
"publishedFareAmount": 1717,
"oneWayFare": true,
"directionality": "FROM",
"direction": "EH",
"notValidBefore": "2019-07-21",
"notValidAfter": "2019-07-21",
"applicablePricingCategories": "4 5 6 7 8 10 12 16 18",
"vendorCode": "ATP",
"fareTypeBitmap": "00",
"fareType": "PRU",
"fareTariff": "4",
"fareRule": "INPL",
"segments": [
{
"segment": {
"surcharges": [
{
"amount": 28.71,
"currency": "NUC",
"description": "MISCELLANEOUS/OTHER",
"type": "Q"
}
]
}
},
{
"segment": {}
},
{
"segment": {}
}
]
}
],
"validatingCarrierDescs": [
{
"id": 1,
"settlementMethod": "ARC",
"newVcxProcess": true,
"default": {
"code": "DL"
}
}
],
"baggageAllowanceDescs": [
{
"id": 1,
"pieceCount": 1
}
],
"legDescs": [
{
"id": 1,
"schedules": [
{
"ref": 2
},
{
"ref": 4,
"departureDateAdjustment": 1
},
{
"ref": 5,
"departureDateAdjustment": 1
}
]
},
{
"id": 2,
"schedules": [
{
"ref": 3
},
{
"ref": 4,
"departureDateAdjustment": 1
},
{
"ref": 1,
"departureDateAdjustment": 1
}
]
}
],
"itineraryGroups": [
{
"groupDescription": {
"legDescriptions": [
{
"departureDate": "2019-07-21",
"departureLocation": "BLR",
"arrivalLocation": "LCY"
}
]
},
"itineraries": [
{
"id": 1,
"pricingSource": "ADVJR1",
"legs": [
{
"ref": 2
}
],
"pricingInformation": [
{
"pricingSubsource": "MIP",
"fare": {
"validatingCarrierCode": "DL",
"vita": true,
"eTicketable": true,
"lastTicketDate": "2019-07-05",
"governingCarriers": "KL",
"passengerInfoList": [
{
"passengerInfo": {
"passengerType": "ADT",
"passengerNumber": 1,
"nonRefundable": true,
"fareComponents": [
{
"ref": 1,
"segments": [
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "D",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "RB",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "L",
"cabinCode": "Y",
"mealCode": "M",
"seatsAvailable": 9,
"availabilityBreak": true
}
}
]
}
],
"taxes": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 7
},
{
"ref": 4
},
{
"ref": 3
},
{
"ref": 5
},
{
"ref": 6
}
],
"taxSummaries": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 3
},
{
"ref": 4
},
{
"ref": 7
},
{
"ref": 5
},
{
"ref": 6
}
],
"currencyConversion": {
"from": "INR",
"to": "USD",
"exchangeRateUsed": 0.01442679
},
"fareMessages": [
{
"type": "N",
"code": "0",
"carrier": "KL",
"info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
},
{
"type": "W",
"code": "0",
"info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
}
],
"passengerTotalFare": {
"totalFare": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"equivalentAmount": 56,
"equivalentCurrency": "USD",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"commissionPercentage": 0,
"commissionAmount": 0,
"exchangeRateOne": 69.651352
},
"baggageInformation": [
{
"provisionType": "A",
"airlineCode": "KL",
"segments": [
{
"id": 0
},
{
"id": 1
},
{
"id": 2
}
],
"allowance": {
"ref": 1
}
}
]
}
}
],
"totalFare": {
"totalPrice": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"equivalentAmount": 56,
"equivalentCurrency": "USD"
},
"validatingCarriers": [
{
"ref": 1
}
]
}
}
],
"diversitySwapper": {
"weighedPrice": 409.855
}
},
{
"id": 2,
"pricingSource": "ADVJR1",
"legs": [
{
"ref": 1
}
],
"pricingInformation": [
{
"pricingSubsource": "MIP",
"fare": {
"validatingCarrierCode": "DL",
"vita": true,
"eTicketable": true,
"lastTicketDate": "2019-07-05",
"governingCarriers": "KL",
"passengerInfoList": [
{
"passengerInfo": {
"passengerType": "ADT",
"passengerNumber": 1,
"nonRefundable": true,
"fareComponents": [
{
"ref": 1,
"segments": [
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "D",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "RB",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "L",
"cabinCode": "Y",
"mealCode": "M",
"seatsAvailable": 9,
"availabilityBreak": true
}
}
]
}
],
"taxes": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 7
},
{
"ref": 4
},
{
"ref": 3
},
{
"ref": 5
},
{
"ref": 6
}
],
"taxSummaries": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 3
},
{
"ref": 4
},
{
"ref": 7
},
{
"ref": 5
},
{
"ref": 6
}
],
"currencyConversion": {
"from": "INR",
"to": "USD",
"exchangeRateUsed": 0.01442679
},
"fareMessages": [
{
"type": "N",
"code": "0",
"carrier": "KL",
"info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
},
{
"type": "W",
"code": "0",
"info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
}
],
"passengerTotalFare": {
"totalFare": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"equivalentAmount": 56,
"equivalentCurrency": "USD",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"commissionPercentage": 0,
"commissionAmount": 0,
"exchangeRateOne": 69.651352
},
"baggageInformation": [
{
"provisionType": "A",
"airlineCode": "KL",
"segments": [
{
"id": 0
},
{
"id": 1
},
{
"id": 2
}
],
"allowance": {
"ref": 1
}
}
]
}
}
],
"totalFare": {
"totalPrice": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"equivalentAmount": 56,
"equivalentCurrency": "USD"
},
"validatingCarriers": [
{
"ref": 1
}
]
}
}
],
"diversitySwapper": {
"weighedPrice": 367.631
}
}
]
}
]
}
}
You have to use legDescs list to connect your segments, and use those "ref" values.
For example:
{
"id": 2,
"schedules": [
{
"ref": 3
},
{
"departureDateAdjustment": 1,
"ref": 4
},
{
"departureDateAdjustment": 1,
"ref": 1
}
]
}
means, your flight with ID = 2 contains 3 segments, with id 3 - 4 and 1. When you search numbered segments in "scheduleDescs" object, you can see routes are:
BLR - DEL
DEL - AMS
AMS - LCY
and as you can see you got the BLR - LCY flight.

papal plus malformed_request JSON with shipping address

To show the Paypal plus iFrame (REST API) i make a Request with JSON
{
"intent": "sale",
"experience_profile_id": "XP-XXXX-XXXX-XXX-XXX",
"redirect_urls": {
"return_url": "https://www.XXXXXXX.de/bestellen.php",
"cancel_url": "https://www.XXXXXXX.de/zahlungabbruch.php"
},
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": "53.45",
"currency": "EUR",
"details": {
"subtotal": "49.5",
"shipping": "3.95"
}
},
"description": "Tollewolle",
"invoice_number": "",
"item_list": {
"items": [
{
"quantity": "4",
"name": "Fine Kid - 50",
"price": "8.25",
"currency": "EUR",
"sku": "8-50"
},
{
"quantity": "2",
"name": "Fine Kid - 208",
"price": "8.25",
"currency": "EUR",
"sku": "8-208"
}
]
},
"shipping_address": {
"line1": "Rechnungs Str. 41",
"city": "Flensburg",
"postal_code": "24939",
"country_code": "DE"
}
}]
}
Without the shipping_address it works fine.
With the address i get an Error 'MALFORMED_REQUEST'
I believe Shipping address is a child ob lineitems so you need to move it up a level. E.g.
"transactions": [{"amount": {"total": "53.45", "currency":
"EUR","details":{"subtotal": "49.5", "shipping":
"3.95"}},"description": "Tollewolle", "invoice_number": "",
"item_list": {"items": [{"quantity": "4", "name": "Fine Kid - 50",
"price": "8.25", "currency": "EUR", "sku": "8-50"},{"quantity": "2",
"name": "Fine Kid - 208","price": "8.25", "currency": "EUR", "sku":
"8-208"}],"shipping_address": {"line1": "Rechnungs Str. 41","city":
"Flensburg", "postal_code": "24939", "country_code": "DE"}}}]