springboot调用第三方接口json转换成对象

  • 请求接口是一个比较常见的需求,接口返回一般是一个json类型,需要进行组装成对应的类,例

    {
    "status_code": 200,
    "message": "success",
    "data": {
    "cost": 286.6933,
    "bom_list": [
    {
    "InvCode": "45601.0077",
    "cInvName": "12.8 OLED 16 pulse BSM",
    "cInvStd": "254.02231.8 mm 12.8寸 16 pulse BSM",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0,
    "parentCode": "20103.0155",
    "totalPrice": 0
    },
    {
    "InvCode": "45001.0056",
    "cInvName": "连接器后盖",
    "cInvStd": "56
    56mm ABS",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.7522,
    "parentCode": "20103.0155",
    "totalPrice": 1.7522
    },
    {
    "InvCode": "45101.0036",
    "cInvName": "Aries 连接器密封圈",
    "cInvStd": "硫化硅胶65° 黑色",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.67,
    "parentCode": "20103.0155",
    "totalPrice": 0.67
    },
    {
    "InvCode": "45505.0039",
    "cInvName": "Force ICS 泡棉支架L-新供应商",
    "cInvStd": "泡棉+双面胶(左)50.5651.127.8mm",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.85,
    "parentCode": "20103.0155",
    "totalPrice": 0.85
    },
    {
    "InvCode": "45505.0040",
    "cInvName": "Force ICS 泡棉支架R-新供应商",
    "cInvStd": "泡棉+双面胶(右)20.63527.8m",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.52,
    "parentCode": "20103.0155",
    "totalPrice": 0.52
    },
    {
    "InvCode": "45403.0011",
    "cInvName": "Force ICS导热片",
    "cInvStd": "24121.2( YL-SP35-S,3w,白色)",
    "BaseQtyN": "4.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.52,
    "parentCode": "20103.0155",
    "totalPrice": 2.08
    },
    {
    "InvCode": "45301.0012",
    "cInvName": "T10头M3L6细牙螺丝",
    "cInvStd": "PM-T10-M3
    L6MM,P=0.35,加磁,渗碳,蓝白锌,盐雾48h",
    "BaseQtyN": "6.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0673,
    "parentCode": "20103.0155",
    "totalPrice": 0.4038
    },
    {
    "InvCode": "45401.0032",
    "cInvName": "Force ICS导电泡棉",
    "cInvStd": "101010",
    "BaseQtyN": "4.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.13,
    "parentCode": "20103.0155",
    "totalPrice": 0.52
    },
    {
    "InvCode": "45801.0062",
    "cInvName": "FPC排线/12.8寸",
    "cInvStd": "一字型/8025.50.3mm/50PIN/PIN距0.5mm/异面/带屏蔽层/带卡扣",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 5.34,
    "parentCode": "20103.0155",
    "totalPrice": 5.34
    },
    {
    "InvCode": "45801.0061",
    "cInvName": "FPC排线/12.8寸",
    "cInvStd": "一字型/5020.50.3mm/40PIN/PIN距0.5mm/异面/带屏蔽层/带卡扣",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 3.219,
    "parentCode": "20103.0155",
    "totalPrice": 3.219
    },
    {
    "InvCode": "30101.0707",
    "cInvName": "PCBA",
    "cInvStd": "ICSCN15_MB_RD1_1/SMT PCBA",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0,
    "parentCode": "20103.0155",
    "totalPrice": 0
    },
    {
    "InvCode": "45504.0013",
    "cInvName": "静电袋",
    "cInvStd": "4004000.05mm/红色/开口长边",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.45,
    "parentCode": "20103.0155",
    "totalPrice": 0.45
    },
    {
    "InvCode": "45202.0052",
    "cInvName": "Pegasus ICS镁合金后盖",
    "cInvStd": "镁合金 AZ91D 240262.2277.13mm/银灰色",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 94.5,
    "parentCode": "20103.0155",
    "totalPrice": 94.5
    },
    {
    "InvCode": "45402.0004",
    "cInvName": "胶水",
    "cInvStd": "SiKa 698,300ml每支",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "400.000000",
    "CompScrap": ".000",
    "cInvDefine13": 481.4157,
    "parentCode": "20103.0155",
    "totalPrice": 1.2035
    },
    {
    "InvCode": "45506.0050",
    "cInvName": "贴纸",
    "cInvStd": "100x100mm,白色合成纸",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "8.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.16,
    "parentCode": "20103.0155",
    "totalPrice": 0.02
    },
    {
    "InvCode": "45506.0044",
    "cInvName": "标签纸",
    "cInvStd": "不干胶1616mm",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.009,
    "parentCode": "20103.0155",
    "totalPrice": 0.009
    },
    {
    "InvCode": "45999.0020",
    "cInvName": "Force ICS保护膜",
    "cInvStd": "SL705U-1,阻抗10^9~10^11/230.2
    252.40.06mm",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.78,
    "parentCode": "20103.0155",
    "totalPrice": 0.78
    },
    {
    "InvCode": "41301.0616",
    "cInvName": "PCB",
    "cInvStd": "ICSCN15_MB_RD1_1/4层板/1.6mm/沉金/绿色哑光/108
    132",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0,
    "parentCode": "30101.0707",
    "totalPrice": 0
    },
    {
    "InvCode": "40201.0053",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "47pF/50V/±5%/C0G/0603/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0177,
    "parentCode": "30101.0707",
    "totalPrice": 0.0177
    },
    {
    "InvCode": "40201.0054",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "4.7NF/50V/±10%/X7R/0603/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0177,
    "parentCode": "30101.0707",
    "totalPrice": 0.0177
    },
    {
    "InvCode": "40201.0037",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "4.7uF/16V/±10%/X5R/0603/Automotive",
    "BaseQtyN": "3.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.075,
    "parentCode": "30101.0707",
    "totalPrice": 0.225
    },
    {
    "InvCode": "40201.0137",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "10uF/10V/±10%/X5R/0603/Automotive",
    "BaseQtyN": "5.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.1668,
    "parentCode": "30101.0707",
    "totalPrice": 0.834
    },
    {
    "InvCode": "40201.0022",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "22uF/10V/±20%/X6S/0805/Automotive",
    "BaseQtyN": "6.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.4312,
    "parentCode": "30101.0707",
    "totalPrice": 2.5872
    },
    {
    "InvCode": "40202.0010",
    "cInvName": "车规电解电容",
    "cInvStd": "22uF/50V/±20%/ECPA/φ6.35.7mm/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.177,
    "parentCode": "30101.0707",
    "totalPrice": 0.177
    },
    {
    "InvCode": "40202.0009",
    "cInvName": "车规电解电容",
    "cInvStd": "100uF/10V/±20%/ECPA/φ6.3
    5.7mm/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.1858,
    "parentCode": "30101.0707",
    "totalPrice": 0.1858
    },
    {
    "InvCode": "40202.0001",
    "cInvName": "车规电解电容",
    "cInvStd": "330uF/35V/±20%/ECPA/φ1010mm/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.4867,
    "parentCode": "30101.0707",
    "totalPrice": 0.4867
    },
    {
    "InvCode": "40101.0077",
    "cInvName": "车规电阻",
    "cInvStd": "0R/5%/1210/Automotive",
    "BaseQtyN": "6.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.036,
    "parentCode": "30101.0707",
    "totalPrice": 0.216
    },
    {
    "InvCode": "40101.0020",
    "cInvName": "车规电阻",
    "cInvStd": "1R/1%/0603/Automotive",
    "BaseQtyN": "4.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0089,
    "parentCode": "30101.0707",
    "totalPrice": 0.0356
    },
    {
    "InvCode": "40101.0123",
    "cInvName": "车规电阻",
    "cInvStd": "1R/1%/1210/0.5W/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.09,
    "parentCode": "30101.0707",
    "totalPrice": 0.09
    },
    {
    "InvCode": "40101.0051",
    "cInvName": "车规电阻",
    "cInvStd": "60.4R/1%/0805/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0086,
    "parentCode": "30101.0707",
    "totalPrice": 0.0172
    },
    {
    "InvCode": "40101.0038",
    "cInvName": "车规电阻",
    "cInvStd": "330R/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40101.0091",
    "cInvName": "车规电阻",
    "cInvStd": "390R/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40101.0023",
    "cInvName": "车规电阻",
    "cInvStd": "1K/5%/0603/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0037,
    "parentCode": "30101.0707",
    "totalPrice": 0.0074
    },
    {
    "InvCode": "40102.0511",
    "cInvName": "工规电阻",
    "cInvStd": "1.02K/0.1%/0402/Industrial",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.065,
    "parentCode": "30101.0707",
    "totalPrice": 0.065
    },
    {
    "InvCode": "40102.0513",
    "cInvName": "工规电阻",
    "cInvStd": "3.6K/0.1%/0402/Industrial",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.065,
    "parentCode": "30101.0707",
    "totalPrice": 0.065
    },
    {
    "InvCode": "40101.0094",
    "cInvName": "车规电阻",
    "cInvStd": "14.3K/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40101.0076",
    "cInvName": "车规电阻",
    "cInvStd": "15K/1%/0603/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0045,
    "parentCode": "30101.0707",
    "totalPrice": 0.0045
    },
    {
    "InvCode": "40101.0095",
    "cInvName": "车规电阻",
    "cInvStd": "16.2K/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40101.0010",
    "cInvName": "车规电阻",
    "cInvStd": "24K/1%/0402/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0054
    },
    {
    "InvCode": "40101.0011",
    "cInvName": "车规电阻",
    "cInvStd": "30K/1%/0402/Automotive",
    "BaseQtyN": "3.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0081
    },
    {
    "InvCode": "40101.0015",
    "cInvName": "车规电阻",
    "cInvStd": "100K/1%/0402/Automotive",
    "BaseQtyN": "11.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0297
    },
    {
    "InvCode": "40104.0003",
    "cInvName": "热敏电阻",
    "cInvStd": "NTC/10K/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.11,
    "parentCode": "30101.0707",
    "totalPrice": 0.11
    },
    {
    "InvCode": "40301.0011",
    "cInvName": "车规电感",
    "cInvStd": "4.7uH/20%/5.5A/40mΩ/7.3
    6.83.0mm/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.27,
    "parentCode": "30101.0707",
    "totalPrice": 1.27
    },
    {
    "InvCode": "40301.0009",
    "cInvName": "车规电感",
    "cInvStd": "10uH/20%/3A/105mΩ/7.3
    6.83.0mm/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.27,
    "parentCode": "30101.0707",
    "totalPrice": 1.27
    },
    {
    "InvCode": "40301.0014",
    "cInvName": "车规电感",
    "cInvStd": "1uH/20%/11A/10mΩ/7.3
    6.83.0mm/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.269,
    "parentCode": "30101.0707",
    "totalPrice": 2.538
    },
    {
    "InvCode": "40303.0010",
    "cInvName": "EMI抑制电感",
    "cInvStd": "Common-mode-choke/51uH/1812/CAN/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.1743,
    "parentCode": "30101.0707",
    "totalPrice": 1.1743
    },
    {
    "InvCode": "40301.0005",
    "cInvName": "车规电感",
    "cInvStd": "Common-mode-choke/90Ω_100MHZ/LVDS/2.0
    1.21.2mm/Automotive",
    "BaseQtyN": "10.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.324,
    "parentCode": "30101.0707",
    "totalPrice": 3.24
    },
    {
    "InvCode": "40301.0030",
    "cInvName": "车规电感",
    "cInvStd": "Common-mode-choke/90Ω_100MHZ/LVDS/2.0
    1.21.2mm/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.469,
    "parentCode": "30101.0707",
    "totalPrice": 0.469
    },
    {
    "InvCode": "40401.0007",
    "cInvName": "车规普通二极管",
    "cInvStd": "60V/5A/0.48V/SOT1289/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.21,
    "parentCode": "30101.0707",
    "totalPrice": 1.21
    },
    {
    "InvCode": "40401.0009",
    "cInvName": "车规普通二极管",
    "cInvStd": "6.8V/10mA/0.9V/SOD-123/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.09,
    "parentCode": "30101.0707",
    "totalPrice": 0.09
    },
    {
    "InvCode": "40402.0007",
    "cInvName": "车规稳压二极管",
    "cInvStd": "28V/1A/0.55V/SOD-123/Automotive",
    "BaseQtyN": "5.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.1283,
    "parentCode": "30101.0707",
    "totalPrice": 0.6415
    },
    {
    "InvCode": "40501.0006",
    "cInvName": "车规TVS管",
    "cInvStd": "ESD/24V/11pF/CAN/bothway/Dual/SOT23/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.3288,
    "parentCode": "30101.0707",
    "totalPrice": 0.3288
    },
    {
    "InvCode": "40501.0003",
    "cInvName": "车规TVS管",
    "cInvStd": "ESD/33V/1500W/bothway/SMC/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.7392,
    "parentCode": "30101.0707",
    "totalPrice": 0.7392
    },
    {
    "InvCode": "40501.0004",
    "cInvName": "车规TVS管",
    "cInvStd": "ESD/5V/150W/bothway/SOD-323/Automotive",
    "BaseQtyN": "3.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.3058,
    "parentCode": "30101.0707",
    "totalPrice": 0.9174
    },
    {
    "InvCode": "40501.0005",
    "cInvName": "车规TVS管",
    "cInvStd": "ESD/5V/0.35pF/bothway/0402/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.2369,
    "parentCode": "30101.0707",
    "totalPrice": 0.4738
    },
    {
    "InvCode": "40801.0003",
    "cInvName": "车规磁珠",
    "cInvStd": "600_100MHZ/25%/1A/0603/Automotive",
    "BaseQtyN": "13.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.1045,
    "parentCode": "30101.0707",
    "totalPrice": 1.3585
    },
    {
    "InvCode": "40701.0009",
    "cInvName": "车规MOS管",
    "cInvStd": "N_MOS/350mA/30V/SOT323/Automotive",
    "BaseQtyN": "9.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.169,
    "parentCode": "30101.0707",
    "totalPrice": 1.521
    },
    {
    "InvCode": "40701.0001",
    "cInvName": "车规MOS管",
    "cInvStd": "P_MOS/-4.2A/-30V/SOT-23/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.3,
    "parentCode": "30101.0707",
    "totalPrice": 0.6
    },
    {
    "InvCode": "41001.0008",
    "cInvName": "车规LED",
    "cInvStd": "2V/25mA/RED/0603/Industrial",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0655,
    "parentCode": "30101.0707",
    "totalPrice": 0.0655
    },
    {
    "InvCode": "41104.0023",
    "cInvName": "电源芯片",
    "cInvStd": "LDO/6.5V-3.3V/1A/HSOP-6J/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.8,
    "parentCode": "30101.0707",
    "totalPrice": 3.6
    },
    {
    "InvCode": "41104.0022",
    "cInvName": "电源芯片",
    "cInvStd": "LDO/36V-5V/200mA/HSOP-6J/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.7,
    "parentCode": "30101.0707",
    "totalPrice": 1.7
    },
    {
    "InvCode": "41104.0025",
    "cInvName": "电源芯片",
    "cInvStd": "LDO/10V-3.3V/300mA/SOT-23-5/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.72,
    "parentCode": "30101.0707",
    "totalPrice": 0.72
    },
    {
    "InvCode": "41104.0087",
    "cInvName": "电源芯片",
    "cInvStd": "DCDC/BUCK/3.5V-36V/3V-10V/3A/400KHZ/TQFN12/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 3.745,
    "parentCode": "30101.0707",
    "totalPrice": 3.745
    },
    {
    "InvCode": "41104.0049",
    "cInvName": "电源芯片",
    "cInvStd": "DCDC/36V-5V/6A/FC2QFN17/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 8.372,
    "parentCode": "30101.0707",
    "totalPrice": 16.744
    },
    {
    "InvCode": "41105.0084",
    "cInvName": "被动芯片",
    "cInvStd": "WATCHDOG/3.3V/SOT23-5/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 2.0708,
    "parentCode": "30101.0707",
    "totalPrice": 2.0708
    },
    {
    "InvCode": "41103.0058",
    "cInvName": "接口芯片",
    "cInvStd": "CAN-transceiver/WAKE-UP/SOP14/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 4.6,
    "parentCode": "30101.0707",
    "totalPrice": 4.6
    },
    {
    "InvCode": "41101.0013",
    "cInvName": "MCU单片机",
    "cInvStd": "MCU/CORTEX-M0/32BIT/80MHZ/LQFP80/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 15.622,
    "parentCode": "30101.0707",
    "totalPrice": 15.622
    },
    {
    "InvCode": "41105.0017",
    "cInvName": "被动芯片",
    "cInvStd": "Touch-IC/71
    IOs/LQFP100/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 27.0259,
    "parentCode": "30101.0707",
    "totalPrice": 27.0259
    },
    {
    "InvCode": "41202.0014",
    "cInvName": "电源连接器",
    "cInvStd": "8PIN/DIP/180度直针/5A/2.5mm-pitch/Black",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 2.35,
    "parentCode": "30101.0707",
    "totalPrice": 2.35
    },
    {
    "InvCode": "41203.0329",
    "cInvName": "信号连接器",
    "cInvStd": "CONNECTOR/HMTD/2P/180度DIP/CODE-A",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 6.17,
    "parentCode": "30101.0707",
    "totalPrice": 6.17
    },
    {
    "InvCode": "41201.0013",
    "cInvName": "FPC连接器",
    "cInvStd": "FPC/卧式/下接/40PIN/500mA/0.5mm-pitch",
    "BaseQtyN": "3.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.4655,
    "parentCode": "30101.0707",
    "totalPrice": 4.3965
    },
    {
    "InvCode": "41201.0014",
    "cInvName": "FPC连接器",
    "cInvStd": "FPC/卧式/下接/50PIN/500mA/0.5mm-pitch",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 1.7242,
    "parentCode": "30101.0707",
    "totalPrice": 1.7242
    },
    {
    "InvCode": "45302.0001",
    "cInvName": "螺母",
    "cInvStd": "M3.0/φ8.0/H13.2mm",
    "BaseQtyN": "4.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.94,
    "parentCode": "30101.0707",
    "totalPrice": 3.76
    },
    {
    "InvCode": "41105.0354",
    "cInvName": "被动芯片",
    "cInvStd": "Deserializer/OLDI 420M/QFN88/CS3.0P",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 49.6496,
    "parentCode": "30101.0707",
    "totalPrice": 49.6496
    },
    {
    "InvCode": "40101.0029",
    "cInvName": "车规电阻",
    "cInvStd": "100R/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40101.0070",
    "cInvName": "车规电阻",
    "cInvStd": "2K/1%/0402/Automotive",
    "BaseQtyN": "71.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.1917
    },
    {
    "InvCode": "40901.0004",
    "cInvName": "车规无源晶振",
    "cInvStd": "27MHZ/8pF/15ppm/3325/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.8142,
    "parentCode": "30101.0707",
    "totalPrice": 0.8142
    },
    {
    "InvCode": "40101.0071",
    "cInvName": "车规电阻",
    "cInvStd": "4.7K/1%/0402/Automotive",
    "BaseQtyN": "13.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0351
    },
    {
    "InvCode": "40101.0072",
    "cInvName": "车规电阻",
    "cInvStd": "10K/1%/0402/Automotive",
    "BaseQtyN": "27.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0729
    },
    {
    "InvCode": "40201.0102",
    "cInvName": "车规电容",
    "cInvStd": "220nF/25V/±10%/X7R/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0552,
    "parentCode": "30101.0707",
    "totalPrice": 0.0552
    },
    {
    "InvCode": "40201.0094",
    "cInvName": "车规电容",
    "cInvStd": "15pF/50V/±5%/C0G/0402/Automotive",
    "BaseQtyN": "5.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0162,
    "parentCode": "30101.0707",
    "totalPrice": 0.081
    },
    {
    "InvCode": "40201.0091",
    "cInvName": "车规电容",
    "cInvStd": "47pF/50V/±5%/C0G/0402/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0176,
    "parentCode": "30101.0707",
    "totalPrice": 0.0352
    },
    {
    "InvCode": "40101.0093",
    "cInvName": "车规电阻",
    "cInvStd": "13.3K/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40201.0051",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "1uF/10V/±10%/X5R/0402/Automotive",
    "BaseQtyN": "23.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.025,
    "parentCode": "30101.0707",
    "totalPrice": 0.575
    },
    {
    "InvCode": "40101.0183",
    "cInvName": "车规电阻",
    "cInvStd": "300K/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40201.0029",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "100nF/50V/±10%/X7R/0603/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0627,
    "parentCode": "30101.0707",
    "totalPrice": 0.1254
    },
    {
    "InvCode": "40101.0184",
    "cInvName": "车规电阻",
    "cInvStd": "200K/1%/0402/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0054
    },
    {
    "InvCode": "40101.0196",
    "cInvName": "车规电阻",
    "cInvStd": "1K/1%/0402/Automotive",
    "BaseQtyN": "18.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0486
    },
    {
    "InvCode": "40101.0198",
    "cInvName": "车规电阻",
    "cInvStd": "0R/5%/0402/Automotive",
    "BaseQtyN": "7.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0021,
    "parentCode": "30101.0707",
    "totalPrice": 0.0147
    },
    {
    "InvCode": "40201.0019",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "2.2uF/16V/±10%/X5R/0603/Automotive",
    "BaseQtyN": "10.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0381,
    "parentCode": "30101.0707",
    "totalPrice": 0.381
    },
    {
    "InvCode": "40201.0017",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "10uF/50V/±10%/X5R/1206/Automotive",
    "BaseQtyN": "8.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.2909,
    "parentCode": "30101.0707",
    "totalPrice": 2.3272
    },
    {
    "InvCode": "40201.0011",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "1uF/50V/±10%/X5R/0603/Automotive",
    "BaseQtyN": "3.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0761,
    "parentCode": "30101.0707",
    "totalPrice": 0.2283
    },
    {
    "InvCode": "40101.0199",
    "cInvName": "车规电阻",
    "cInvStd": "33R/5%/0402/Automotive",
    "BaseQtyN": "23.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0021,
    "parentCode": "30101.0707",
    "totalPrice": 0.0483
    },
    {
    "InvCode": "40201.0008",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "100nF/50V/±10%/X7R/0402/Automotive",
    "BaseQtyN": "78.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0175,
    "parentCode": "30101.0707",
    "totalPrice": 1.365
    },
    {
    "InvCode": "40101.0200",
    "cInvName": "车规电阻",
    "cInvStd": "0R/1%/0805/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0086,
    "parentCode": "30101.0707",
    "totalPrice": 0.0172
    },
    {
    "InvCode": "40201.0006",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "10NF/50V/±10%/X7R/0402/Automotive",
    "BaseQtyN": "12.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0109,
    "parentCode": "30101.0707",
    "totalPrice": 0.1308
    },
    {
    "InvCode": "40201.0004",
    "cInvName": "车规陶瓷电容",
    "cInvStd": "1nF/50V/±10%/X7R/0402/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0109,
    "parentCode": "30101.0707",
    "totalPrice": 0.0218
    },
    {
    "InvCode": "40101.0202",
    "cInvName": "车规电阻",
    "cInvStd": "0R/5%/0603/Automotive",
    "BaseQtyN": "3.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0037,
    "parentCode": "30101.0707",
    "totalPrice": 0.0111
    },
    {
    "InvCode": "40101.0217",
    "cInvName": "车规电阻",
    "cInvStd": "10K/0.1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0,
    "parentCode": "30101.0707",
    "totalPrice": 0
    },
    {
    "InvCode": "40101.0214",
    "cInvName": "车规电阻",
    "cInvStd": "2.2K/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40101.0210",
    "cInvName": "车规电阻",
    "cInvStd": "1M/1%/0402/Automotive",
    "BaseQtyN": "2.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0054
    },
    {
    "InvCode": "40101.0086",
    "cInvName": "车规电阻",
    "cInvStd": "12K/1%/0402/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.0027,
    "parentCode": "30101.0707",
    "totalPrice": 0.0027
    },
    {
    "InvCode": "40901.0024",
    "cInvName": "车规无源晶振",
    "cInvStd": "16MHZ/8pF/30ppm/3225/Automotive",
    "BaseQtyN": "1.000000",
    "BaseQtyD": "1.000000",
    "CompScrap": ".000",
    "cInvDefine13": 0.791,
    "parentCode": "30101.0707",
    "totalPrice": 0.791
    }
    ]
    }
    }

  • 上面的接口返回,我们只需要将data中的数据封装成一个对象类,我们想封装一个list中的对象

java 复制代码
public class BomCost implements Serializable {
    private String InvCode;
    private String cInvName;
    private String cInvStd;
    private BigDecimal BaseQtyN;
    private BigDecimal BaseQtyD;
    private BigDecimal CompScrap;
    private BigDecimal cInvDefine13;
    private String parentCode;
    private BigDecimal totalPrice;
}
  • 封装data中数据对应对象
java 复制代码
public class MaterialCost {
    private BigDecimal cost;
    private List<BomCost> bom_list;
}
  • 现在将接口的data数据封装到对象MaterialCost
java 复制代码
    public MaterialCost one(String code) throws JsonProcessingException {
        RestTemplate restTemplate = new RestTemplate();
        String url = "xxxxxxxx?code={?}";
        ResponseEntity<String> entity = restTemplate.getForEntity(url, String.class, code);
        JSONObject jsonArray = JSONArray.parseObject(entity.getBody());
        JSONObject data = jsonArray.getJSONObject("data");
        System.out.println(data.getBigDecimal("cost"));
        JSONArray bom_list = data.getJSONArray("bom_list");
        MaterialCost materialCost = new MaterialCost();
        materialCost.setCost(data.getBigDecimal("cost"));
        List<BomCost> bomCostList = new ArrayList<>();
        for (Object o : bom_list) {
            BomCost bomCost = new BomCost();
            JSONObject object = JSONArray.parseObject(o.toString());
            bomCost.setInvCode(object.getString("InvCode"));
            bomCost.setCInvName(object.getString("cInvName"));
            bomCost.setCInvStd(object.getString("cInvStd"));
            bomCost.setParentCode(object.getString("parentCode"));
            bomCost.setBaseQtyN(object.getBigDecimal("BaseQtyN"));
            bomCost.setBaseQtyD(object.getBigDecimal("BaseQtyD"));
            bomCost.setCompScrap(object.getBigDecimal("CompScrap"));
            bomCost.setCInvDefine13(object.getBigDecimal("cInvDefine13"));
            bomCost.setTotalPrice(object.getBigDecimal("totalPrice"));
            bomCostList.add(bomCost);
        }
        materialCost.setBom_list(bomCostList);
        return materialCost;
    }
  • 封装后的结果,跟接口数据一致
相关推荐
LuckyLay7 分钟前
Spring学习笔记_27——@EnableLoadTimeWeaving
java·spring boot·spring
佳佳_1 小时前
Spring Boot 应用启动时打印配置类信息
spring boot·后端
程序媛小果2 小时前
基于java+SpringBoot+Vue的宠物咖啡馆平台设计与实现
java·vue.js·spring boot
努力的家伙是不讨厌的4 小时前
解析json导出csv或者直接入库
开发语言·python·json
狂放不羁霸4 小时前
idea | 搭建 SpringBoot 项目之配置 Maven
spring boot·maven·intellij-idea
计算机学长felix5 小时前
基于SpringBoot的“校园交友网站”的设计与实现(源码+数据库+文档+PPT)
数据库·spring boot·毕业设计·交友
码农派大星。5 小时前
Spring Boot 配置文件
java·spring boot·后端
江深竹静,一苇以航5 小时前
springboot3项目整合Mybatis-plus启动项目报错:Invalid bean definition with name ‘xxxMapper‘
java·spring boot
豪宇刘6 小时前
SpringBoot+Shiro权限管理
java·spring boot·spring
customer086 小时前
【开源免费】基于SpringBoot+Vue.JS医院管理系统(JAVA毕业设计)
java·vue.js·spring boot·后端·spring cloud·开源·intellij-idea