php在json编码时添加奇怪的值

时间:2014-11-19 15:42:58

标签: javascript php json

我正在使用Angular JS将 $ scope 传递给PHP文件,然后将其写入json文件。

问题是我在JSON文件中添加了很奇怪的值,当我第一次在我的Angular控制器中调试对象时,这些值不存在。

我哪里错了?

这是json在发送到php文件之前的样子:

{
    "questionaires": [{
        "id": 1,
            "category": 1,
            "name": "first",
            "description": "hello there",
    }, {
        "id": 3,
            "category": 1,
            "name": "shelter help",
            "description": "wooo",
    }, {
        "id": 2,
            "category": 1,
            "name": "second",
            "description": "ad"
    }]
}

PHP文件:

  $completeJSON = json_encode($build);

  // create JSON file for the tool
  $createJSON = fopen($filename, 'c+') or die("can't open file " . $filename);
  fwrite($createJSON,$completeJSON);
  fclose($createJSON);

写的JSON:

{
"questionaires": [{
    "id": 1,
        "category": 1,
        "name": "first",
        "description": "hello there",
        "spc_fIamk": 0,
        "idx_fIamk": 0,
        "spc_eWuTq": 0,
        "idx_eWuTq": 0,
        "spc_SPmhT": 0,
        "idx_SPmhT": 0,
        "spc_zCXIF": 0,
        "idx_zCXIF": 0,
        "spc_DhDWQ": 0,
        "idx_DhDWQ": 0,
        "spc_RZHJk": 0,
        "idx_RZHJk": 0,
        "spc_qwobJ": 0,
        "idx_qwobJ": 0,
        "spc_AUGuF": 0,
        "idx_AUGuF": 0,
        "spc_xzzIC": 0,
        "idx_xzzIC": 0,
        "spc_VuhCa": 0,
        "idx_VuhCa": 0,
        "spc_tvqfe": 0,
        "idx_tvqfe": 0,
        "spc_aoCgw": 0,
        "idx_aoCgw": 0,
        "spc_ksQOL": 0,
        "idx_ksQOL": 0,
        "spc_UGNnh": 0,
        "idx_UGNnh": 0,
        "spc_puEKS": 0,
        "idx_puEKS": 0,
        "spc_scihJ": 0,
        "idx_scihJ": 0,
        "spc_edbhv": 0,
        "idx_edbhv": 0,
        "spc_tNZwT": 0,
        "idx_tNZwT": 0,
        "spc_adGUZ": 0,
        "idx_adGUZ": 0,
        "spc_jwtPf": 0,
        "idx_jwtPf": 0,
        "spc_ULdzk": 0,
        "idx_ULdzk": 0,
        "spc_rzKHb": 0,
        "idx_rzKHb": 0,
        "spc_OpvkT": 0,
        "idx_OpvkT": 0,
        "spc_Poyti": 0,
        "idx_Poyti": 0,
        "spc_NsIWQ": 0,
        "idx_NsIWQ": 0,
        "spc_SDdHp": 0,
        "idx_SDdHp": 0,
        "spc_xhFdD": 0,
        "idx_xhFdD": 0,
        "spc_uZCyo": 0,
        "idx_uZCyo": 0,
        "spc_CJxIs": 0,
        "idx_CJxIs": 0,
        "spc_NnqXd": 0,
        "idx_NnqXd": 0,
        "spc_qaVIA": 0,
        "idx_qaVIA": 0,
        "spc_hPNmQ": 0,
        "idx_hPNmQ": 0
}, {
    "id": 3,
        "category": 1,
        "name": "shelter help",
        "description": "wooo",
        "spc_AUGuF": 0,
        "idx_AUGuF": 2,
        "spc_xzzIC": 0,
        "idx_xzzIC": 2,
        "spc_VuhCa": 0,
        "idx_VuhCa": 1,
        "spc_tvqfe": 0,
        "idx_tvqfe": 1,
        "spc_aoCgw": 0,
        "idx_aoCgw": 1,
        "spc_ksQOL": 0,
        "idx_ksQOL": 1,
        "spc_UGNnh": 0,
        "idx_UGNnh": 1,
        "spc_puEKS": 0,
        "idx_puEKS": 1,
        "spc_scihJ": 0,
        "idx_scihJ": 1,
        "spc_edbhv": 0,
        "idx_edbhv": 1,
        "spc_tNZwT": 0,
        "idx_tNZwT": 1,
        "spc_adGUZ": 0,
        "idx_adGUZ": 1,
        "spc_jwtPf": 0,
        "idx_jwtPf": 1,
        "spc_ULdzk": 0,
        "idx_ULdzk": 1,
        "spc_rzKHb": 0,
        "idx_rzKHb": 1,
        "spc_OpvkT": 0,
        "idx_OpvkT": 1,
        "spc_Poyti": 0,
        "idx_Poyti": 1,
        "spc_NsIWQ": 0,
        "idx_NsIWQ": 1,
        "spc_SDdHp": 0,
        "idx_SDdHp": 1,
        "spc_xhFdD": 0,
        "idx_xhFdD": 1,
        "spc_uZCyo": 0,
        "idx_uZCyo": 1,
        "spc_CJxIs": 0,
        "idx_CJxIs": 1,
        "spc_NnqXd": 0,
        "idx_NnqXd": 1,
        "spc_qaVIA": 0,
        "idx_qaVIA": 1,
        "spc_hPNmQ": 0,
        "idx_hPNmQ": 1
}, {
    "id": 2,
        "category": 1,
        "name": "second",
        "description": "ad"
}]
}

0 个答案:

没有答案