For example, givent this JSON object:
{
name: 'Tony',
age: '20',
birthday: '20180101',
}
How can I turn it as parameters to attach to the end of a restful GET API URL like this?
/API/data?name=Tony&age=20&birthday=20180101
For example, givent this JSON object:
{
name: 'Tony',
age: '20',
birthday: '20180101',
}
How can I turn it as parameters to attach to the end of a restful GET API URL like this?
/API/data?name=Tony&age=20&birthday=20180101
You can use jQuery
.param
function:
var object = {
name: 'Tony',
age: '20',
birthday: '20180101',
};
console.log($.param(object));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>