xxxxxxxxxx
data.response.result.Countries.row.filter(function (el) {
return (el.FL[0].content == "USA");
})[0].FL[1];
xxxxxxxxxx
function queryStringToJson(queryString) {
// Remove leading '?' if present
if (queryString.charAt(0) === '?') {
queryString = queryString.slice(1);
}
// Split query string into key-value pairs
const keyValuePairs = queryString.split('&');
// Convert key-value pairs into JSON object
const json = {};
keyValuePairs.forEach((keyValuePair) => {
const [key, value] = keyValuePair.split('=');
json[key] = decodeURIComponent(value);
});
return json;
}
// Example usage
const query = 'param1=value1¶m2=value2¶m3=value3';
const json = queryStringToJson(query);
console.log(json);
xxxxxxxxxx
import urllib.parse
json_object = {
"name": "John",
"age": 30,
"city": "New York"
}
query_string = urllib.parse.urlencode(json_object)
print(query_string)