Php 为什么Json_encode返回空数组?

Php 为什么Json_encode返回空数组?,php,json,Php,Json,以下是我正在使用的json: { "data": [{ "Contact_Name": { "id": "1884053000034678068" }, "Subject": "1 - XKBKNABJK", "Status": "Sans Impact Stock", "Entity": "", "Etat": "CM - Annul\u00e9",

以下是我正在使用的json:

{
    "data": [{
        "Contact_Name": {
            "id": "1884053000034678068"
        },
        "Subject": "1 - XKBKNABJK",
        "Status": "Sans Impact Stock",
        "Entity": "",
        "Etat": "CM - Annul\u00e9",
        "Invoice_Date": "2017-11-21",
        "Discount": 0.000000,
        "Tax": ["TVA"],
        "Total_HT": "55.000000",
        "Total_TVA": 0,
        "Methode_de_paiement": "Payment by check",
        "ID_Lip": "1",
        "Origine": "CM",
        "Type_de_Facture": "Solde",
        "Transporteur": "My carrier",
        "Reference_Colis": "",
        "Billing_Street": "16, Main street",
        "Compl_ment_Facturation": "2nd floor",
        "Billing_City": "Miami",
        "Billing_Country": "\u00c9tats-Unis",
        "Billing_Code": "33133",
        "Shipping_Street": "16, Main street",
        "Compl_ment_Livraison": "2nd floor",
        "Shipping_City": "Miami",
        "Shipping_Country": "\u00c9tats-Unis",
        "Shipping_Code": "33133",
        "Product_Details": [{
            "product": {
                "id": "1884053000030235273"
            },
            "Product_Name": Blouse - Color: White,
             Size: M,
            "list_price": 22.5,
            "quantity": 1,
            "Discount": 0,
            "Discount_Amount": 0,
                "line_tax": [{
                "percentage": 20,
                "name": "TVA"
            }]
        }, {
            "product": {
                "id": "1884053000030235273"
            },
            "Product_Name": Printed Dress - Color: Orange,
            Size: S,
            "list_price": 21.67,
            "quantity": 1,
            "Discount": 0,
            "Discount_Amount": 0,
            "line_tax": [{
                "percentage": 20,
                "name": "TVA"
            }]
        }, {
            "product": {
                "id": "1884053000012868763"
            }, 
            "list_price": 1.67,
            "quantity": 1,
            "Discount": 0,
            "Discount_Amount": 0,
            "line_tax": [{
                "percentage": 20,
                "name": "TVA"
            }]
        }],
        "Adjustment": 0,
        "Montant_TPH": 0,
        "TVA_sur_DEEE_TPH": "0",
        "Taxes_DEEE_TPH": "TPH",
        "Frais_de_port_HT": "2.000000",
        "Frais_de_port_TTC": "2.000000",
        "Nb_produits": 3,
        "Quantite_totale": 3
    }],
    "duplicate_check_fields": ["ID_Lip"],
    "trigger": []
}
但是,当我使用json_encode()函数时,它不会返回一个对象json,而只是返回一个空数组,而且我在代码中也没有看到任何语法错误。我不知道这是真的语法错误还是别的什么。。有人能帮我知道问题出在哪里吗? 提前谢谢你

解决方案 改用
json\u解码($jsondata,true)

详细说明:

要使用的Propper JSON 您的json字符串中还有一个错误

以下是要使用的propper json:

{
    "data": [{
        "Contact_Name": {
            "id": "1884053000034678068"
        },
        "Subject": "1 - XKBKNABJK",
        "Status": "Sans Impact Stock",
        "Entity": "",
        "Etat": "CM - Annul\u00e9",
        "Invoice_Date": "2017-11-21",
        "Discount": 0.000000,
        "Tax": ["TVA"],
        "Total_HT": "55.000000",
        "Total_TVA": 0,
        "Methode_de_paiement": "Payment by check",
        "ID_Lip": "1",
        "Origine": "CM",
        "Type_de_Facture": "Solde",
        "Transporteur": "My carrier",
        "Reference_Colis": "",
        "Billing_Street": "16, Main street",
        "Compl_ment_Facturation": "2nd floor",
        "Billing_City": "Miami",
        "Billing_Country": "\u00c9tats-Unis",
        "Billing_Code": "33133",
        "Shipping_Street": "16, Main street",
        "Compl_ment_Livraison": "2nd floor",
        "Shipping_City": "Miami",
        "Shipping_Country": "\u00c9tats-Unis",
        "Shipping_Code": "33133",
        "Product_Details": [{
            "product": {
                "id": "1884053000030235273"
            },
            "Product_Name": "Blouse - Color: White, Size: M",
            "list_price": 22.5,
            "quantity": 1,
            "Discount": 0,
            "Discount_Amount": 0,
                "line_tax": [{
                "percentage": 20,
                "name": "TVA"
            }]
        }, {
            "product": {
                "id": "1884053000030235273"
            },
            "Product_Name": "Printed Dress - Color: Orange, Size: S",
            "list_price": 21.67,
            "quantity": 1,
            "Discount": 0,
            "Discount_Amount": 0,
            "line_tax": [{
                "percentage": 20,
                "name": "TVA"
            }]
        }, {
            "product": {
                "id": "1884053000012868763"
            }, 
            "list_price": 1.67,
            "quantity": 1,
            "Discount": 0,
            "Discount_Amount": 0,
            "line_tax": [{
                "percentage": 20,
                "name": "TVA"
            }]
        }],
        "Adjustment": 0,
        "Montant_TPH": 0,
        "TVA_sur_DEEE_TPH": "0",
        "Taxes_DEEE_TPH": "TPH",
        "Frais_de_port_HT": "2.000000",
        "Frais_de_port_TTC": "2.000000",
        "Nb_produits": 3,
        "Quantite_totale": 3
    }],
    "duplicate_check_fields": ["ID_Lip"],
    "trigger": []
}
为了未来 检查json以获得安全的结果


我希望这有帮助

您的json在“产品名称”附近的语法中有错误

价值观​​必须是字符串,因此介于“”之间

如果您有解决问题,请告诉我们:)


祝你有愉快的一天

这已经是
编码的
数据,因此请使用
json\u decode()
将其转换为数组问题中的json不是有效的json,它有几个语法错误。请尝试使用确定错误欢迎使用堆栈溢出!请拿着(你得到了一个徽章!),四处看看,仔细阅读,特别是我还推荐乔恩·斯基特的。我们无法帮助您处理无法看到的代码。请用一个(注意“最小值”)来更新这个问题,它演示了这个问题。我确实纠正了错误,它是有效的!