I´m new on JSON /JAVASCRIPT. This is whhat i have
JSON OBJECT
const object = {
"id": "123412341243",
"intent": "CAPTURE",
"purchase_units": [
{
"reference_id": "PU1",
"amount": {
"currency_code": "EUR",
"value": "18.98",
"breakdown": {
"item_total": {
"currency_code": "EUR",
"value": "18.98"
},
"shipping": {
"currency_code": "EUR",
"value": "0.00"
},
"handling": {
"currency_code": "EUR",
"value": "0.00"
},
"tax_total": {
"currency_code": "EUR",
"value": "0.00"
},
"insurance": {
"currency_code": "EUR",
"value": "0.00"
},
"shipping_discount": {
"currency_code": "EUR",
"value": "0.00"
}
}
},
"payee": {
"email_address": "c...r@gmail.com",
"merchant_id": "848UWWSMK2TC4"
},
"description": "InfoPosit",
"custom_id": "1231231231",
"invoice_id": "Iabcabc",
"items": [
{
"name": "PRODUCTO 1",
"unit_amount": {
"currency_code": "EUR",
"value": "8.99"
},
"quantity": "1",
"sku": "fi78PSRA"
},
{
"name": "PRODUCTO 2",
"unit_amount": {
"currency_code": "EUR",
"value": "9.99"
},
"quantity": "1",
"sku": "fi11PMSRA"
},
{
"name": "PRODUCTO 3",
"unit_amount": {
"currency_code": "EUR",
"value": "9.99"
},
"quantity": "1",
"sku": "fi11PMSRA"
}
],
"shipping": {
"name": {
"full_name": "test buyer"
},
"address": {
"address_line_1": "15 Mary Street",
"admin_area_2": "North Sydney",
"admin_area_1": "NSW",
"postal_code": "2001",
"country_code": "AU"
}
}
}
],
"payer": {
"name": {
"given_name": "test",
"surname": "buyer"
},
"email_address": "c......r@gmail.com",
"payer_id": "AAAAAAAAAA",
"address": {
"country_code": "ES"
}
},
"create_time": "2020-05-10T00:36:33Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/21312312",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/123123123",
"rel": "update",
"method": "PATCH"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/123123123/capture",
"rel": "capture",
"method": "POST"
}
],
"status": "APPROVED"
}
Whith this code i get the NAME value from ITEMS... but i dont know how to put each value into a INPUT.
i´m trying to Get all names (purchase_units.items.name) and values (purchase_units.items.unit_amount.value) from my obbject and insert them each one in a input HTML.
JAVSCRIPT file
var key =new Array();
var key1= object.purchase_units[0].items;
for(var i=0, len=key1.length; i<len; i++) {
key[i] = object.purchase_units[0].items[i].name;
}
console.log(key);
i´ve tried searchin on enternet .. but after some days of searching i tough that some one here can help me..