G
G
Gabe Jonson2015-11-17 16:38:44
JavaScript
Gabe Jonson, 2015-11-17 16:38:44

Outputting an object in one line?

There is an object {
'1':1,
'2':2,
'3':3
}
and there is a link in which you need to stuff it all ... But you get only 3 links with different values, how can you throw this whole object, for example , in href to have something

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wol_fi, 2015-11-17
@gabejonson

var obj = {
'1':1,
'2':2,
'3':3
};
var serializedObj = JSON.stringify(obj);
var encodedObj = encodeURIComponent(serializedObj);
var link = 'http://blabla.com/blabla?obj=' + encodedObj;
console.log(link);

More or less like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question