json_encode将NULL添加到JSON输出结尾

时间:2018-01-25 10:23:57

标签: json null

以下函数成功从我的WordPress表返回预期的JSON,但是" null"添加在字符串的末尾。我在stackoverflow上尝试过一些建议,但没有任何效果。任何指针都会非常感激。

function see_get_basic_accuracy() {
  global $wpdb;

  $userid = apply_filters( 'determine_current_user', false );
  wp_set_current_user( $userid );
  $userID = get_current_user_id();

  $sql = "
    SELECT *
    FROM basic_accuracy_table
    WHERE user_id = $userID
    ORDER BY recent_session ASC
    LIMIT 1;
    ";

  $results = $wpdb->get_results($sql);
  $json = json_encode($results);

  echo $json;
}

这是输出:

[{" ID":" 4264"" SESSION_COUNT":" 700""会话&#34 ;: "会话 - 700"," Session_Date":" 2018-01-04 16:00:06"," user_id":&#34 1""困难":"具有基本"" tot_pct":" 32"" tot_abs" :" 8"" length_pct":" 20"" width_pct":" 20"" angle_pct":" 0"" curvature_pct":" 80"" location_pct":" 40&#34 ;, " length_abs":" 1"" width_abs":" 1"" angle_abs":" 0& #34;" curvature_abs":" 4"" location_abs":" 2"" lead_value":空," Recent_Session":" 1"," comb_label":" 700,1/4 / 201,4:00 PM,na,na,na& #34;," comb_label_ordered":" 700,1 / 4 / 201,4:00 PM,na,na,na,1,1,1,0,4,2,8, 20,20,0,80,40,32"}] null

0 个答案:

没有答案