如何在PHP中获取JSON对象数组

时间:2019-11-10 13:49:39

标签: php json

{
  "HEADER": {
    "TALLYREQUEST": "Import Data"
  },
  "BODY": {
    "IMPORTDATA": {
      "REQUESTDESC": {
        "REPORTNAME": "Vouchers",
        "STATICVARIABLES": {
          "SVCURRENTCOMPANY": "Kraiburg"
        }
      },
      "REQUESTDATA": {
        "TALLYMESSAGE": [{
          "VOUCHER": {
            "@attributes": {
              "REMOTEID": "93584c36-9ad4-47d1-ac37-0205053cd15e-00000137",
              "VCHKEY": "93584c36-9ad4-47d1-ac37-0205053cd15e-0000ab00:00000008",
              "VCHTYPE": "Sales",
              "ACTION": "Create",
              "OBJVIEW": "Invoice Voucher View"
            },
            "OLDAUDITENTRYIDS.LIST": {
              "@attributes": {
                "TYPE": "Number"
              },
              "OLDAUDITENTRYIDS": "-1"
            },
            "DATE": "20191108",
            "GUID": "93584c36-9ad4-47d1-ac37-0205053cd15e-00000137",
            "STATENAME": "Karnataka",
            "COUNTRYOFRESIDENCE": "India",
            "PARTYNAME": "Party A",
            "VOUCHERTYPENAME": "Sales",
            "VOUCHERNUMBER": "2",
            "PARTYLEDGERNAME": "Party A",
            "BASICBASEPARTYNAME": "Party A",
            "CSTFORMISSUETYPE": {},
            "CSTFORMRECVTYPE": {},
            "FBTPAYMENTTYPE": "Default",
            "PERSISTEDVIEW": "Invoice Voucher View",
            "PLACEOFSUPPLY": "Karnataka",
            "BASICBUYERNAME": "Party A",
            "BASICDATETIMEOFINVOICE": "8-Nov-2019 at 16:02",
            "BASICDATETIMEOFREMOVAL": "8-Nov-2019 at 16:02",
            "VCHGSTCLASS": {},
            "CONSIGNEESTATENAME": "Karnataka",
            "ENTEREDBY": "a",
            "DIFFACTUALQTY": "No",
            "ISMSTFROMSYNC": "No",
            "ASORIGINAL": "No",
            "AUDITED": "No",
            "FORJOBCOSTING": "No",
            "ISOPTIONAL": "No",
            "EFFECTIVEDATE": "20191108",
            "USEFOREXCISE": "No",
            "ISFORJOBWORKIN": "No",
            "ALLOWCONSUMPTION": "No",
            "USEFORINTEREST": "No",
            "USEFORGAINLOSS": "No",
            "USEFORGODOWNTRANSFER": "No",
            "USEFORCOMPOUND": "No",
            "USEFORSERVICETAX": "No",
            "ISEXCISEVOUCHER": "No",
            "EXCISETAXOVERRIDE": "No",
            "USEFORTAXUNITTRANSFER": "No",
            "IGNOREPOSVALIDATION": "No",
            "EXCISEOPENING": "No",
            "USEFORFINALPRODUCTION": "No",
            "ISTDSOVERRIDDEN": "No",
            "ISTCSOVERRIDDEN": "No",
            "ISTDSTCSCASHVCH": "No",
            "INCLUDEADVPYMTVCH": "No",
            "ISSUBWORKSCONTRACT": "No",
            "ISVATOVERRIDDEN": "No",
            "IGNOREORIGVCHDATE": "No",
            "ISVATPAIDATCUSTOMS": "No",
            "ISDECLAREDTOCUSTOMS": "No",
            "ISSERVICETAXOVERRIDDEN": "No",
            "ISISDVOUCHER": "No",
            "ISEXCISEOVERRIDDEN": "No",
            "ISEXCISESUPPLYVCH": "No",
            "ISGSTOVERRIDDEN": "No",
            "GSTNOTEXPORTED": "No",
            "IGNOREGSTINVALIDATION": "No",
            "ISVATPRINCIPALACCOUNT": "No",
            "ISBOENOTAPPLICABLE": "No",
            "ISSHIPPINGWITHINSTATE": "No",
            "ISOVERSEASTOURISTTRANS": "No",
            "ISDESIGNATEDZONEPARTY": "No",
            "ISCANCELLED": "No",
            "HASCASHFLOW": "No",
            "ISPOSTDATED": "No",
            "USETRACKINGNUMBER": "No",
            "ISINVOICE": "Yes",
            "MFGJOURNAL": "No",
            "HASDISCOUNTS": "No",
            "ASPAYSLIP": "No",
            "ISCOSTCENTRE": "No",
            "ISSTXNONREALIZEDVCH": "No",
            "ISEXCISEMANUFACTURERON": "No",
            "ISBLANKCHEQUE": "No",
            "ISVOID": "No",
            "ISONHOLD": "No",
            "ORDERLINESTATUS": "No",
            "VATISAGNSTCANCSALES": "No",
            "VATISPURCEXEMPTED": "No",
            "ISVATRESTAXINVOICE": "No",
            "VATISASSESABLECALCVCH": "No",
            "ISVATDUTYPAID": "Yes",
            "ISDELIVERYSAMEASCONSIGNEE": "No",
            "ISDISPATCHSAMEASCONSIGNOR": "No",
            "ISDELETED": "No",
            "CHANGEVCHMODE": "No",
            "ALTERID": " 743",
            "MASTERID": " 311",
            "VOUCHERKEY": "188016488349704",
            "EXCLUDEDTAXATIONS.LIST": {
              "0": "      "
            },
            "OLDAUDITENTRIES.LIST": {
              "0": "      "
            },
            "ACCOUNTAUDITENTRIES.LIST": {
              "0": "      "
            },
            "AUDITENTRIES.LIST": {
              "0": "      "
            },
            "DUTYHEADDETAILS.LIST": {
              "0": "      "
            },
            "SUPPLEMENTARYDUTYHEADDETAILS.LIST": {
              "0": "      "
            },
            "EWAYBILLDETAILS.LIST": {
              "0": "      "
            },
            "INVOICEDELNOTES.LIST": {
              "0": "      "
            },
            "INVOICEORDERLIST.LIST": {
              "0": "      "
            },
            "INVOICEINDENTLIST.LIST": {
              "0": "      "
            },
            "ATTENDANCEENTRIES.LIST": {
              "0": "      "
            },
            "ORIGINVOICEDETAILS.LIST": {
              "0": "      "
            },
            "INVOICEEXPORTLIST.LIST": {
              "0": "      "
            },
            "LEDGERENTRIES.LIST": {
              "OLDAUDITENTRYIDS.LIST": {
                "@attributes": {
                  "TYPE": "Number"
                },
                "OLDAUDITENTRYIDS": "-1"
              },
              "LEDGERNAME": "Party A",
              "GSTCLASS": {},
              "ISDEEMEDPOSITIVE": "Yes",
              "LEDGERFROMITEM": "No",
              "REMOVEZEROENTRIES": "No",
              "ISPARTYLEDGER": "Yes",
              "ISLASTDEEMEDPOSITIVE": "Yes",
              "ISCAPVATTAXALTERED": "No",
              "ISCAPVATNOTCLAIMED": "No",
              "AMOUNT": "-400.00",
              "SERVICETAXDETAILS.LIST": {
                "0": "       "
              },
              "BANKALLOCATIONS.LIST": {
                "0": "       "
              },
              "BILLALLOCATIONS.LIST": {
                "NAME": "2",
                "BILLCREDITPERIOD": "10 Days",
                "BILLTYPE": "New Ref",
                "TDSDEDUCTEEISSPECIALRATE": "No",
                "AMOUNT": "-400.00",
                "INTERESTCOLLECTION.LIST": {
                  "0": "        "
                },
                "STBILLCATEGORIES.LIST": {
                  "0": "        "
                }
              },
              "INTERESTCOLLECTION.LIST": {
                "0": "       "
              },
              "OLDAUDITENTRIES.LIST": {
                "0": "       "
              },
              "ACCOUNTAUDITENTRIES.LIST": {
                "0": "       "
              },
              "AUDITENTRIES.LIST": {
                "0": "       "
              },
              "INPUTCRALLOCS.LIST": {
                "0": "       "
              },
              "DUTYHEADDETAILS.LIST": {
                "0": "       "
              },
              "EXCISEDUTYHEADDETAILS.LIST": {
                "0": "       "
              },
              "RATEDETAILS.LIST": {
                "0": "       "
              },
              "SUMMARYALLOCS.LIST": {
                "0": "       "
              },
              "STPYMTDETAILS.LIST": {
                "0": "       "
              },
              "EXCISEPAYMENTALLOCATIONS.LIST": {
                "0": "       "
              },
              "TAXBILLALLOCATIONS.LIST": {
                "0": "       "
              },
              "TAXOBJECTALLOCATIONS.LIST": {
                "0": "       "
              },
              "TDSEXPENSEALLOCATIONS.LIST": {
                "0": "       "
              },
              "VATSTATUTORYDETAILS.LIST": {
                "0": "       "
              },
              "COSTTRACKALLOCATIONS.LIST": {
                "0": "       "
              },
              "REFVOUCHERDETAILS.LIST": {
                "0": "       "
              },
              "INVOICEWISEDETAILS.LIST": {
                "0": "       "
              },
              "VATITCDETAILS.LIST": {
                "0": "       "
              },
              "ADVANCETAXDETAILS.LIST": {
                "0": "       "
              }
            },
            "ALLINVENTORYENTRIES.LIST": {
              "STOCKITEMNAME": "Item 1",
              "ISDEEMEDPOSITIVE": "No",
              "ISLASTDEEMEDPOSITIVE": "No",
              "ISAUTONEGATE": "No",
              "ISCUSTOMSCLEARANCE": "No",
              "ISTRACKCOMPONENT": "No",
              "ISTRACKPRODUCTION": "No",
              "ISPRIMARYITEM": "No",
              "ISSCRAP": "No",
              "RATE": "400.00\/Nos",
              "AMOUNT": "400.00",
              "ACTUALQTY": " 1 Nos",
              "BILLEDQTY": " 1 Nos",
              "BATCHALLOCATIONS.LIST": {
                "GODOWNNAME": "Damaged GoDown",
                "BATCHNAME": "213",
                "DESTINATIONGODOWNNAME": "Damaged GoDown",
                "INDENTNO": {},
                "ORDERNO": {},
                "TRACKINGNUMBER": {},
                "DYNAMICCSTISCLEARED": "No",
                "AMOUNT": "400.00",
                "ACTUALQTY": " 1 Nos",
                "BILLEDQTY": " 1 Nos",
                "ADDITIONALDETAILS.LIST": {
                  "0": "        "
                },
                "VOUCHERCOMPONENTLIST.LIST": {
                  "0": "        "
                }
              },
              "ACCOUNTINGALLOCATIONS.LIST": {
                "OLDAUDITENTRYIDS.LIST": {
                  "@attributes": {
                    "TYPE": "Number"
                  },
                  "OLDAUDITENTRYIDS": "-1"
                },
                "LEDGERNAME": "Sales",
                "GSTCLASS": {},
                "ISDEEMEDPOSITIVE": "No",
                "LEDGERFROMITEM": "No",
                "REMOVEZEROENTRIES": "No",
                "ISPARTYLEDGER": "No",
                "ISLASTDEEMEDPOSITIVE": "No",
                "ISCAPVATTAXALTERED": "No",
                "ISCAPVATNOTCLAIMED": "No",
                "AMOUNT": "400.00",
                "SERVICETAXDETAILS.LIST": {
                  "0": "        "
                },
                "BANKALLOCATIONS.LIST": {
                  "0": "        "
                },
                "BILLALLOCATIONS.LIST": {
                  "0": "        "
                },
                "INTERESTCOLLECTION.LIST": {
                  "0": "        "
                },
                "OLDAUDITENTRIES.LIST": {
                  "0": "        "
                },
                "ACCOUNTAUDITENTRIES.LIST": {
                  "0": "        "
                },
                "AUDITENTRIES.LIST": {
                  "0": "        "
                },
                "INPUTCRALLOCS.LIST": {
                  "0": "        "
                },
                "DUTYHEADDETAILS.LIST": {
                  "0": "        "
                },
                "EXCISEDUTYHEADDETAILS.LIST": {
                  "0": "        "
                },
                "RATEDETAILS.LIST": {
                  "0": "        "
                },
                "SUMMARYALLOCS.LIST": {
                  "0": "        "
                },
                "STPYMTDETAILS.LIST": {
                  "0": "        "
                },
                "EXCISEPAYMENTALLOCATIONS.LIST": {
                  "0": "        "
                },
                "TAXBILLALLOCATIONS.LIST": {
                  "0": "        "
                },
                "TAXOBJECTALLOCATIONS.LIST": {
                  "0": "        "
                },
                "TDSEXPENSEALLOCATIONS.LIST": {
                  "0": "        "
                },
                "VATSTATUTORYDETAILS.LIST": {
                  "0": "        "
                },
                "COSTTRACKALLOCATIONS.LIST": {
                  "0": "        "
                },
                "REFVOUCHERDETAILS.LIST": {
                  "0": "        "
                },
                "INVOICEWISEDETAILS.LIST": {
                  "0": "        "
                },
                "VATITCDETAILS.LIST": {
                  "0": "        "
                },
                "ADVANCETAXDETAILS.LIST": {
                  "0": "        "
                }
              },
              "DUTYHEADDETAILS.LIST": {
                "0": "       "
              },
              "SUPPLEMENTARYDUTYHEADDETAILS.LIST": {
                "0": "       "
              },
              "TAXOBJECTALLOCATIONS.LIST": {
                "0": "       "
              },
              "REFVOUCHERDETAILS.LIST": {
                "0": "       "
              },
              "EXCISEALLOCATIONS.LIST": {
                "0": "       "
              },
              "EXPENSEALLOCATIONS.LIST": {
                "0": "       "
              }
            },
            "PAYROLLMODEOFPAYMENT.LIST": {
              "0": "      "
            },
            "ATTDRECORDS.LIST": {
              "0": "      "
            },
            "GSTEWAYCONSIGNORADDRESS.LIST": {
              "0": "      "
            },
            "GSTEWAYCONSIGNEEADDRESS.LIST": {
              "0": "      "
            },
            "TEMPGSTRATEDETAILS.LIST": {
              "0": "      "
            }
          }
        }, {
          "COMPANY": {
            "REMOTECMPINFO.LIST": {
              "@attributes": {
                "MERGE": "Yes"
              },
              "NAME": "93584c36-9ad4-47d1-ac37-0205053cd15e",
              "REMOTECMPNAME": "Kraiburg",
              "REMOTECMPSTATE": "Karnataka"
            }
          }
        }, {
          "COMPANY": {
            "REMOTECMPINFO.LIST": {
              "@attributes": {
                "MERGE": "Yes"
              },
              "NAME": "93584c36-9ad4-47d1-ac37-0205053cd15e",
              "REMOTECMPNAME": "Kraiburg",
              "REMOTECMPSTATE": "Karnataka"
            }
          }
        }]
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

<?php
$json ='<replace with your large json string>';
$array = json_decode($json, true);
var_dump($array);

您可以在http://sandbox.onlinephpfunctions.com/上尝试