我有一个字符串,我想从中获取JSON值

时间:2016-11-12 14:54:27

标签: javascript node.js

嗨我有一个文本字符串,我想得到Va rog sa ne trimiteti locatia的值。

我的文字字符串是{“text”:“Va rog sa ne trimiteti locatia”}

谢谢

1 个答案:

答案 0 :(得分:-1)

您可以使用JSON.parse()函数将字符串解析为对象文字:

function is_user_has_unapproved ( $comments, $user_id ) {
    $i = 0;
    foreach ( $comments as $comment ) {
        if ( $comment->user_id == $user_id ) {
            if ( $comment->comment_approved == "0" ) {
                $i++;
            }
        }
    }

    if ( $i != 0 ) {
        return true;
    } else {
        return false;
    }
}