我有以下JSON。它验证,但不会使用PHP json_decode解码。任何想法从哪里开始?
[
{
"Borrower":" SystemDisc ",
"Title / Type / Term Votes":"Business+personal - max 5% total Loan type: Business 20.00000000 BTC for 180 days paid every 30 days 20",
"Country % Funded":" ",
"Invested Date Listed Reputation":"24% funded",
"":" 2014-10-11 14:07 CDT",
"":"100.00 % positive +49, 0"
},
{
"Borrower":" vitobeta ",
"Title / Type / Term Votes":"Bitfinex loan #2 - 4-5% monthly Loan type: Investing 3000.00 USD for 180 days paid every 30 days 16",
"Country % Funded":" ",
"Invested Date Listed Reputation":"76.7% funded",
"":" 2014-10-05 13:47 CDT",
"":"100.00 % positive +225, 0"
},
{
"Borrower":" joenobody211 ",
"Title / Type / Term Votes":"Restructure Plan pt1 24% Loan type: Debt Consolidation 8.45000000 BTC for 180 days paid every 30 days 13",
"Country % Funded":" ",
"Invested Date Listed Reputation":"26% funded",
"":" 2014-10-16 18:05 CDT",
"":"100.00 % positive +294, 0"
},
{
"Borrower":" TexasKEK ",
"Title / Type / Term Votes":"30 days @ 15% or less Loan type: Business 1000.00 USD for 30 days paid every 30 days 13",
"Country % Funded":" ",
"Invested Date Listed Reputation":"56% funded",
"":" 2014-10-02 04:44 CDT",
"":"100.00 % positive +82, 0"
},
{
"Borrower":" bitcoin24 ",
"Title / Type / Term Votes":"Website Upgrade [max 15%] Loan type: Investing 1.50000000 BTC for 90 days paid every 30 days 11",
"Country % Funded":" ",
"Invested Date Listed Reputation":"23.7% funded",
"":" 2014-10-14 07:24 CDT",
"":"100.00 % positive +71, 0"
},
{
"Borrower":" canhada ",
"Title / Type / Term Votes":"# 1 investment in gawminner p... Loan type: Investing 6.50000000 BTC for 120 days paid every 14 days 11",
"Country % Funded":" ",
"Invested Date Listed Reputation":"21.4% funded",
"":" 2014-10-08 16:01 CDT",
"":"100.00 % positive +84, 0"
},
{
"Borrower":" Mrocean ",
"Title / Type / Term Votes":"Buying Equity stocks, little ... Loan type: Business 12.00000000 BTC for 60 days paid every 14 days 8",
"Country % Funded":" ",
"Invested Date Listed Reputation":"100% funded",
"":" 2014-10-20 03:44 CDT",
"":"100.00 % positive +397, 0"
},
{
"Borrower":" reasilvabr ",
"Title / Type / Term Votes":"Coffeebit.io 15/35 Loan type: Business 5.00000000 BTC for 360 days paid every 30 days 8",
"Country % Funded":" ",
"Invested Date Listed Reputation":"25.7% funded",
"":" 2014-10-15 11:16 CDT",
"":"100.00 % positive +234, 0"
},
{
"Borrower":" mattthebat ",
"Title / Type / Term Votes":"Investing up to 20% Loan type: Investing 400.00 USD for 30 days paid every 30 days 8",
"Country % Funded":" ",
"Invested Date Listed Reputation":"19% funded",
"":" 2014-10-07 05:15 CDT",
"":"100.00 % positive +20, 0"
},
{
"Borrower":" Ohotenco ",
"Title / Type / Term Votes":"Loan for 2 weeks Loan type: Other 0.27000000 BTC for 14 days paid every 7 days 7",
"Country % Funded":" ",
"Invested Date Listed Reputation":"67.9% funded",
"":" 2014-10-17 16:13 CDT",
"":"0 % positive +0, 0"
}
]
答案 0 :(得分:1)
如果你正确编码它可以正常工作
<?php
$t = '[ {"Borrower":" SystemDisc ","Title / Type / Term Votes":"Business+personal - max 5% total Loan type: Business 20.00000000 BTC for 180 days paid every 30 days 20","Country % Funded":" ","Invested Date Listed Reputation":"24% funded","":" 2014-10-11 14:07 CDT","":"100.00 % positive +49, 0"},
{"Borrower":" vitobeta ","Title / Type / Term Votes":"Bitfinex loan #2 - 4-5% monthly Loan type: Investing 3000.00 USD for 180 days paid every 30 days 16","Country % Funded":" ","Invested Date Listed Reputation":"76.7% funded","":" 2014-10-05 13:47 CDT","":"100.00 % positive +225, 0"},
{"Borrower":" joenobody211 ","Title / Type / Term Votes":"Restructure Plan pt1 24% Loan type: Debt Consolidation 8.45000000 BTC for 180 days paid every 30 days 13","Country % Funded":" ","Invested Date Listed Reputation":"26% funded","":" 2014-10-16 18:05 CDT","":"100.00 % positive +294, 0"},
{"Borrower":" TexasKEK ","Title / Type / Term Votes":"30 days @ 15% or less Loan type: Business 1000.00 USD for 30 days paid every 30 days 13","Country % Funded":" ","Invested Date Listed Reputation":"56% funded","":" 2014-10-02 04:44 CDT","":"100.00 % positive +82, 0"},
{"Borrower":" bitcoin24 ","Title / Type / Term Votes":"Website Upgrade [max 15%] Loan type: Investing 1.50000000 BTC for 90 days paid every 30 days 11","Country % Funded":" ","Invested Date Listed Reputation":"23.7% funded","":" 2014-10-14 07:24 CDT","":"100.00 % positive +71, 0"},
{"Borrower":" canhada ","Title / Type / Term Votes":"# 1 investment in gawminner p... Loan type: Investing 6.50000000 BTC for 120 days paid every 14 days 11","Country % Funded":" ","Invested Date Listed Reputation":"21.4% funded","":" 2014-10-08 16:01 CDT","":"100.00 % positive +84, 0"},
{"Borrower":" Mrocean ","Title / Type / Term Votes":"Buying Equity stocks, little ... Loan type: Business 12.00000000 BTC for 60 days paid every 14 days 8","Country % Funded":" ","Invested Date Listed Reputation":"100% funded","":" 2014-10-20 03:44 CDT","":"100.00 % positive +397, 0"},
{"Borrower":" reasilvabr ","Title / Type / Term Votes":"Coffeebit.io 15/35 Loan type: Business 5.00000000 BTC for 360 days paid every 30 days 8","Country % Funded":" ","Invested Date Listed Reputation":"25.7% funded","":" 2014-10-15 11:16 CDT","":"100.00 % positive +234, 0"},
{"Borrower":" mattthebat ","Title / Type / Term Votes":"Investing up to 20% Loan type: Investing 400.00 USD for 30 days paid every 30 days 8","Country % Funded":" ","Invested Date Listed Reputation":"19% funded","":" 2014-10-07 05:15 CDT","":"100.00 % positive +20, 0"},
{"Borrower":" Ohotenco ","Title / Type / Term Votes":"Loan for 2 weeks Loan type: Other 0.27000000 BTC for 14 days paid every 7 days 7","Country % Funded":" ","Invested Date Listed Reputation":"67.9% funded","":" 2014-10-17 16:13 CDT","":"0 % positive +0, 0"}]';
print_r(json_decode($t));
给出一个非常好的数组
Array
(
[0] => stdClass Object
(
[Borrower] => SystemDisc
[Title / Type / Term Votes] => Business+personal - max 5% total Loan type: Business 20.00000000 BTC for 180 days paid every 30 days 20
[Country % Funded] =>
[Invested Date Listed Reputation] => 24% funded
[_empty_] => 100.00 % positive +49, 0
)
[1] => stdClass Object
(
[Borrower] => vitobeta
[Title / Type / Term Votes] => Bitfinex loan #2 - 4-5% monthly Loan type: Investing 3000.00 USD for 180 days paid every 30 days 16
[Country % Funded] =>
[Invested Date Listed Reputation] => 76.7% funded
[_empty_] => 100.00 % positive +225, 0
)
[2] => stdClass Object
(
[Borrower] => joenobody211
[Title / Type / Term Votes] => Restructure Plan pt1 24% Loan type: Debt Consolidation 8.45000000 BTC for 180 days paid every 30 days 13
[Country % Funded] =>
[Invested Date Listed Reputation] => 26% funded
[_empty_] => 100.00 % positive +294, 0
)
[3] => stdClass Object
(
[Borrower] => TexasKEK
[Title / Type / Term Votes] => 30 days @ 15% or less Loan type: Business 1000.00 USD for 30 days paid every 30 days 13
[Country % Funded] =>
[Invested Date Listed Reputation] => 56% funded
[_empty_] => 100.00 % positive +82, 0
)
[4] => stdClass Object
(
[Borrower] => bitcoin24
[Title / Type / Term Votes] => Website Upgrade [max 15%] Loan type: Investing 1.50000000 BTC for 90 days paid every 30 days 11
[Country % Funded] =>
[Invested Date Listed Reputation] => 23.7% funded
[_empty_] => 100.00 % positive +71, 0
)
[5] => stdClass Object
(
[Borrower] => canhada
[Title / Type / Term Votes] => # 1 investment in gawminner p... Loan type: Investing 6.50000000 BTC for 120 days paid every 14 days 11
[Country % Funded] =>
[Invested Date Listed Reputation] => 21.4% funded
[_empty_] => 100.00 % positive +84, 0
)
[6] => stdClass Object
(
[Borrower] => Mrocean
[Title / Type / Term Votes] => Buying Equity stocks, little ... Loan type: Business 12.00000000 BTC for 60 days paid every 14 days 8
[Country % Funded] =>
[Invested Date Listed Reputation] => 100% funded
[_empty_] => 100.00 % positive +397, 0
)
[7] => stdClass Object
(
[Borrower] => reasilvabr
[Title / Type / Term Votes] => Coffeebit.io 15/35 Loan type: Business 5.00000000 BTC for 360 days paid every 30 days 8
[Country % Funded] =>
[Invested Date Listed Reputation] => 25.7% funded
[_empty_] => 100.00 % positive +234, 0
)
[8] => stdClass Object
(
[Borrower] => mattthebat
[Title / Type / Term Votes] => Investing up to 20% Loan type: Investing 400.00 USD for 30 days paid every 30 days 8
[Country % Funded] =>
[Invested Date Listed Reputation] => 19% funded
[_empty_] => 100.00 % positive +20, 0
)
[9] => stdClass Object
(
[Borrower] => Ohotenco
[Title / Type / Term Votes] => Loan for 2 weeks Loan type: Other 0.27000000 BTC for 14 days paid every 7 days 7
[Country % Funded] =>
[Invested Date Listed Reputation] => 67.9% funded
[_empty_] => 0 % positive +0, 0
)
)
虽然我不知道有一个空的字段名称""
是合法的,但似乎转换为_empty_
但是,我建议任何提出字段命名约定的人都需要另外尝试合理的字段名称,只是为了使这个数据结构更容易编码和理解。