我如何在React Native中从json中选择特定值?

时间:2018-11-19 13:32:59

标签: javascript reactjs react-native

我要获取的是选择“质量”的“ url”值是hd720

组件

    componentDidMount() {

       return fetch('https://you-link.herokuapp.com/?url=https://www.youtube.com/watch?v=YGCLs9Bt_KY')
         .then((response) => response.json())
         .then((responseJson) => {
           this.setState({
             isLoading: false,
             dataSource: responseJson,
             videoUrl: responseJson[0].url
           }, function() {
           });
         })
         .catch((error) => {
           console.error(error);
         });
     }

Json Call
Link

1 个答案:

答案 0 :(得分:4)

您只需搜索匹配条件(Using find)的JSON数组 在这种情况下,“质量” ===“ hd720”

SSLContext sslContext = SSLContexts.custom()
        .loadTrustMaterial((chain, authType) -> true)
        .build();

CloseableHttpClient client = HttpClients.custom()
        .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext,
                new String[]{"SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"},
                null,
                NoopHostnameVerifier.INSTANCE))
        .build();