{"SchemeName":"胡田窯遺跡(ひょうたん窯、馬蹄窯)人体保護工学設計計画","SchemeType":"技術計画(第三者委託)","Declare Year":"2014","SchemeStatus ": "検討中","省":"江西省"},{"SchemeName":"袁中都遺跡の南門と宮殿都市南西隅の版築保護プロジェクト","SchemeType":"技術的スキーム(第三者への委託) ","Declare Year":"2014","SchemeStatus":"検討中","Province":"河北省"},{"SchemeName":"袁中都遺跡環境改善プロジェクト", "SchemeType":"技術スキーム(第三者委託)","Declare Year":"2014","SchemeStatus":"検討中","Province":"河北省"},{"SchemeName":"Neiqiu Xing Kiln Site Protection Greenhouse", "SchemeType":"技術的ソリューション (第三者に委託)","Declare Year":"2014","SchemeStatus":"検討中","Province":"河北省"}
配列に変換する方法
右括弧を追加します
エンコーディングは utf-8 である必要があることに注意してください
$s =<<< TXT[{"SchemeName":"湖田窑遗址(葫芦窑、马蹄窑)本体保护工程设计方案","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"江西省"},{"SchemeName":"元中都遗址宫城南门、西南角台夯土保护工程","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"},{"SchemeName":"元中都遗址环境整治工程","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"},{"SchemeName":"内丘邢窑遗址保护大棚","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"}]TXT;print_r(json_decode($s, 1));
Array( [0] => Array ( [SchemeName] => 湖田窑遗址(葫芦窑、马蹄窑)本体保护工程设计方案 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 江西省 ) [1] => Array ( [SchemeName] => 元中都遗址宫城南门、西南角台夯土保护工程 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 河北省 ) [2] => Array ( [SchemeName] => 元中都遗址环境整治工程 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 河北省 ) [3] => Array ( [SchemeName] => 内丘邢窑遗址保护大棚 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 河北省 ))
$str = <<<phps[{"SchemeName":"湖田窑遗址(葫芦窑、马蹄窑)本体保护工程设计方案","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"江西省"},{"SchemeName":"元中都遗址宫城南门、西南角台夯土保护工程","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"},{"SchemeName":"元中都遗址环境整治工程","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"},{"SchemeName":"内丘邢窑遗址保护大棚","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"}]phps;var_dump(json_decode($str,true));
両側に [] を追加しますjson_decode を使用して配列に変換します
正しい角かっこを追加します
エンコーディングは utf-8
$s =<<< TXT[{"SchemeName":"湖田窑遗址(葫芦窑、马蹄窑)本体保护工程设计方案","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"江西省"},{"SchemeName":"元中都遗址宫城南门、西南角台夯土保护工程","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"},{"SchemeName":"元中都遗址环境整治工程","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"},{"SchemeName":"内丘邢窑遗址保护大棚","SchemeType":"技术方案(委托第三方)","DeclareYear":"2014","SchemeStatus":"评审中","Province":"河北省"}]TXT;print_r(json_decode($s, 1));
Array( [0] => Array ( [SchemeName] => 湖田窑遗址(葫芦窑、马蹄窑)本体保护工程设计方案 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 江西省 ) [1] => Array ( [SchemeName] => 元中都遗址宫城南门、西南角台夯土保护工程 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 河北省 ) [2] => Array ( [SchemeName] => 元中都遗址环境整治工程 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 河北省 ) [3] => Array ( [SchemeName] => 内丘邢窑遗址保护大棚 [SchemeType] => 技术方案(委托第三方) [DeclareYear] => 2014 [SchemeStatus] => 评审中 [Province] => 河北省 ))である必要があることに注意してください