-1

ターゲット フィールドの元の値を保持し、json_decode を使用して次の文字列をオブジェクトとして使用します。

{
    "translatorID": "f4a5876a-3e53-40e2-9032-d99a30d7a6fc",
    "label": "ACL",
    "creator": "Nathan Schneider",
    "target": "^https?://(www[.])?aclweb\\.org/anthology-new/[^#]+",
    "minVersion": "1.0.7",
    "maxVersion": "",
    "priority": 100,
    "browserSupport": "gcs",
    "inRepository": true,
    "translatorType": 4,
    "lastUpdated": "2012-01-01 01:42:16"
}
4

2 に答える 2

1

スラッシュを削除しようとしましたか?

これは私のために働いた:

$string = '{
    "translatorID": "f4a5876a-3e53-40e2-9032-d99a30d7a6fc",
    "label": "ACL",
    "creator": "Nathan Schneider",
    "target": "^https?://(www[.])?aclweb\.org/anthology-new/[^#]+",
    "minVersion": "1.0.7",
    "maxVersion": "",
    "priority": 100,
    "browserSupport": "gcs",
    "inRepository": true,
    "translatorType": 4,
    "lastUpdated": "2012-01-01 01:42:16"
}';

var_dump( json_decode(stripslashes ($string)));
于 2012-06-19T11:52:45.247 に答える
1

解析する前にできることjson_decodeは次のとおりです。

$string = str_replace('\\', '\\\\\\\\', $string);
var_dump(json_decode($string, true));

これは、json パーサーのバグに違いありません。
この方法はあまりきれいではありませんが、少なくとも結果は得られています。

于 2012-06-19T11:31:44.053 に答える