this is a prices.json file which contains many products prices i need iterate over this .json in order to compare with another json output from another system
i need to get only the fields "MATNR" field which contains the product ID and "NET_PRICE" = contain the price before VAT and "PRICE_INC_TAX" = contain the price after VAT
[
{
"customer": {
"AUART": "",
"KALSM": "ZDPS00",
"KUNNR": "0001234567",
"SPRAS": "",
"VKGRP": "",
"VKORG": "1000",
"VTWEG": "10",
"ZMDD": "99",
"ZTERM": ""
},
"outdated": false,
"outputs": [
{
"KUNNR": "0001234567",
"KWMENG": "1",
"MATNR": "000000000001000001",
"NET_PRICE": "15.50",
"NET_PRICE_PER_BASE_UNIT": "15.50",
"ORDER": "1",
"PRICE_INC_TAX": "18.13",
"PRICE_INC_TAX_PER_BASE_UNIT": "18.13",
"TOTAL_TIME": "Total Calculation Time: 15ms",
"VRKME": "EA",
"converted_quantity": "1.00"
},
{
"KUNNR": "0001234567",
"KWMENG": "1",
"MATNR": "000000000001000002",
"NET_PRICE": "20.00",
"NET_PRICE_PER_BASE_UNIT": "20.00",
"ORDER": "1",
"PRICE_INC_TAX": "23.40",
"PRICE_INC_TAX_PER_BASE_UNIT": "23.40",
"TOTAL_TIME": "Total Calculation Time: 12ms",
"VRKME": "EA",
"converted_quantity": "1.00"
},
{
"KUNNR": "0001234567",
"KWMENG": "1",
"MATNR": "000000000001000003",
"NET_PRICE": "20.00",
"NET_PRICE_PER_BASE_UNIT": "21.00",
"ORDER": "1",
"PRICE_INC_TAX": "24.40",
"PRICE_INC_TAX_PER_BASE_UNIT": "24.40",
"TOTAL_TIME": "Total Calculation Time: 12ms",
"VRKME": "EA",
"converted_quantity": "1.00"
}
]
}
]
this is the block of code I'm trying get the specific values but it's still not works:
public static void parseJson() {
JSONParser jsonP = new JSONParser();
try (FileReader reader = new FileReader("MyJson.json")) {
// Read JSON File
Object obj = jsonP.parse(reader);
JSONArray priceList = ((JSONArray) obj).get("outputs");
//1) getting error above line "The method get(int) in the type ArrayList is not applicable for the arguments (String)"
//2) TODO: here I want to iterate only the "MATNR", "NET_PRICE", PRICE_INC_TAX values
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}
I'll be so thankful who can solve me two questions on this method! Thanks in advance