How i can select a specific value from json?

get specific value from json
access and print a specific json value
get value from nested json object in javascript
json get value by key
how to get value from json object
json nested arrays
json.parse array of objects
loop through json object

What I'm trying to get is to select the "url" value of the "medium-mp4"

Component

    componentDidMount() {

       return fetch('https://you-link.herokuapp.com')
         .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

The response is not an array, it's an object, so you can't use 0. Try the object key you want instead.

{
  videoUrl: responseJson['hd720-mp4'].url
}

Access and print a specific JSON value, Getting a specific property from a JSON response object. JSON wouldn't be very useful if you always had to print out the entire response. Instead, you select the  Extracts a scalar value from a JSON string. To extract an object or an array from a JSON string instead of a scalar value, see JSON_QUERY (Transact-SQL). For info about the differences between JSON_VALUE and JSON_QUERY, see Compare JSON_VALUE and JSON_QUERY. Transact-SQL Syntax Conventions.

                let objMusic = JSON.parse('{"hd720-mp4":{"itag":"22","quality":"hd720","type":"video/mp4","url":"https://r5---sn-5uaezn6y.googlevideo.com/videoplayback?mn=sn-5uaezn6y,sn-q4flrnl7&mm=31,26&id=o-AID9zwFrzXB9sFZjRYPFuJyVV_ViYTpwz40-0Po2qR-P&c=WEB&mime=video/mp4&lmt=1537717779316991&ip=2a02:4780:1:3::f&pl=48&itag=22&dur=295.706&mv=u&source=youtube&ms=au,onr&fvip=5&ei=sKPzW-6XIZCPj-8PzruZ-A4&requiressl=yes&sparams=dur,ei,id,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&mt=1542693264&expire=1542715408&ipbits=0&key=yt6&signature=B59110AC6E15FAE514C4B18679750702C9069E83.B0AC77A3AEBC7EC3CE20D218C67E8AE80E745E8A&ratebypass=yes&signature="},"medium-webm":{"itag":"43","quality":"medium","type":"video/webm","url":"https://r5---sn-5uaezn6y.googlevideo.com/videoplayback?mn=sn-5uaezn6y,sn-q4flrnl7&mm=31,26&id=o-AID9zwFrzXB9sFZjRYPFuJyVV_ViYTpwz40-0Po2qR-P&lmt=1540750584717310&ip=2a02:4780:1:3::f&pl=48&dur=0.000&mv=u&source=youtube&ms=au,onr&ei=sKPzW-6XIZCPj-8PzruZ-A4&sparams=clen,dur,ei,gir,id,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&mt=1542693264&expire=1542715408&txp=5511222&key=yt6&gir=yes&ipbits=0&c=WEB&mime=video/webm&itag=43&fvip=5&ratebypass=yes&requiressl=yes&clen=30067021&signature=238FF11CC09F405CFD24423203F813EDFB5D66C2.3003162315BC1FF6A5D0C3B19BB03F9E1016E780&signature="},"medium-mp4":{"itag":"18","quality":"medium","type":"video/mp4","url":"https://r5---sn-5uaezn6y.googlevideo.com/videoplayback?mn=sn-5uaezn6y,sn-q4flrnl7&mm=31,26&id=o-AID9zwFrzXB9sFZjRYPFuJyVV_ViYTpwz40-0Po2qR-P&lmt=1537716294977165&ip=2a02:4780:1:3::f&pl=48&dur=295.706&mv=u&source=youtube&ms=au,onr&ei=sKPzW-6XIZCPj-8PzruZ-A4&sparams=clen,dur,ei,gir,id,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&mt=1542693264&expire=1542715408&key=yt6&gir=yes&ipbits=0&c=WEB&mime=video/mp4&itag=18&fvip=5&ratebypass=yes&requiressl=yes&clen=23503941&signature=DA800A9574CBF4EA8666390C6F98562A70EBE3EE.9C3BD58181B597C780E5264498B0919D2B0B8453&signature="},"small-3gpp":{"itag":"17","quality":"small","type":"video/3gpp","url":"https://r5---sn-5uaezn6y.googlevideo.com/videoplayback?mn=sn-5uaezn6y,sn-q4flrnl7&mm=31,26&txp=5531232&id=o-AID9zwFrzXB9sFZjRYPFuJyVV_ViYTpwz40-0Po2qR-P&c=WEB&sparams=clen,dur,ei,gir,id,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,requiressl,source,expire&mime=video/3gpp&lmt=1540636712468197&ip=2a02:4780:1:3::f&pl=48&itag=17&dur=295.729&mv=u&source=youtube&ms=au,onr&fvip=5&ei=sKPzW-6XIZCPj-8PzruZ-A4&requiressl=yes&clen=2800636&mt=1542693264&expire=1542715408&ipbits=0&key=yt6&signature=4E618E1E6289DAC12A897896C9D2DEDA304DB55D.2240D0C7E9911C62537A948D6795EF7E171AA7CC&gir=yes&signature="}}')
                if (objMusic['medium-mp4']) {
                    let mp4 = objMusic['medium-mp4']
                    let url = mp4.url
                    alert(JSON.stringify(url))
                }

You can use above to get the url value.

JSON Objects, Each key/value pair is separated by a comma. Accessing Object Values. You can access the object values by using dot (.) notation: Example. myObj  you can get value for that JSON value as. response.data.data[0]["username"] If you want to get all the usernames from the array, then you can do something like this:

Try this code snippet

videoUrl: responseJson['medium-mp4'].url

Extract specific values from nested JSOn output - Build, Hello All, I need to get specific values from output json. Like from below ListA= (​From p In obj(“data”)(“transactionsummary”) Select Convert. jQuery Practical Exercises with Solution: Select values from a JSON object using jQuery.

responseJson['hd720-mp4']['url']

SQL/JSON Condition JSON_EXISTS, json_exists lets you use a SQL/JSON path expression as a row filter, to select rows Condition json_exists checks for the existence of a particular value within​  Instead, you select the exact property you want and pull that out through dot notation. The dot (.) after response (the name of the JSON payload, as defined arbitrarily in the jQuery AJAX function) is how you access the values you want from the JSON object.

Documentation: 9.4: JSON Functions and Operators, You may want to view the same page for the current version, or one of the supported input (either json or jsonb), except for those specified as returning text, which coerce setof text, Expands a JSON array to a set of text values. select * from  In the above highlighted code snippet we are passing the JSON object, containing the criteria for selection of JSON objects, to pass to the sql javascript function. The JSON object contains the following keys. select: Mention the keys/properties you want to select out of the JSON object.

Using JSON Filters, filters, with the following type values (logical operators): In a select key, you can select specific fields from specific data shapes that you want to be returned by  On the HTTP trigger, to be able to play easier with the JSON payload, you can click on the option Use a sample payload to generate schema and copy/paste the sample JSON above, to generate a body JSON schema and with that, the runtime will create proper tokens for the objects and properties

Working with JSON Data, Greenplum Database supports JSON as specified in the RFC 7159 document and values can be numbers, quoted strings, true, false, or null SELECT '5'::json​;  need to get this value from the above json data "attributeValue": "7776000000" What I have tried: The below is my code that i have tried to fetch the specific value dynamic Result = JsonConvert.DeserializeObject(jsonResultFromAPI); foreach (var item in Result ) { retentionPeriod = item.attributes.attributeValue;//API Value; }

Comments
  • videoUrl: responseJson["medium-mp4"].url
  • Did you try responseJson[0]['medium-mp4'].url ?
  • I've tried it and it does not work
  • Please post the console.log(responseJson)
  • jsoneditoronline.org/?id=e0c8c701dc5d4fa69797b3737b7fd5db
  • I have tried this but not work: componentDidMount() { return fetch('www.url.com') .then((response) => response.json()) .then((responseJson) => { let url = responseJson.find(obj => obj.responseJson['hd720-mp4']).url this.setState({ isLoading: false, dataSource: responseJson, videoUrl: url }, function() {}); }) .catch((error) => { console.error(error); }); }
  • You checked as "right answer" the same thing I told you to do lol