Array conversion issue
Hello friends,
I am trying (in Javascript an Coldfusion) to convert: {"val1":"member","val2":"book","val3":"journal","val4":"new_member","val5":"cds"},
into this: { member,book,journal,new_member,cds}
Notice that I am trying to eliminate quotes.
Is it possible to achieve that? How can I do it?
Thanks
Tom
I am trying this:
Code:
<script type="text/javascript">
// http://www.webdeveloper.com/forum/showthread.php?t=260748
var A = {
"val1":"member",
"val2":"book",
"val3":"journal",
"val4":"new_member",
"val5":"cds"
}
// http://www.w3schools.com/json/json_intro.asp
// http://www.w3schools.com/json/json_syntax.asp
// http://www.w3schools.com/json/tryit.asp?filename=tryjson_eval
// http://www.w3schools.com/jsref/jsref_toSource_date.asp
alert(A.toSource()); // ({val1:"member", val2:"book", val3:"journal", val4:"new_member", val5:"cds"})
var txt = '{'+A.val1 + ',' + A.val2 + ',' + A.val3 + ',' + A.val4 + ',' + A.val5 + '}'
alert ( txt ); // { member,book,journal,new_member,cds}
var txt = '{'+A.val1 + ',' + A.val2 + ',' + A.val3 + ',' + A.val4 + ',' + A.val5 + '}'
alert ( txt ); // { member,book,journal,new_member,cds}
// txt = txt.replace(/"/g,"");
// alert(txt);
var txt = '{'+A.val1 + ': "zülkarneyn" ,' + A.val2 + ':4,' + A.val3 + ':2016,' + A.val4 + ':"süleyman",' + A.val5 + ':2022 }';
var A = eval ("(" + txt + ")");
alert( A );
alert(A.toSource());
alert(A.member); // zülkarneyn
alert(A.book); // 4
alert(A.journal); // 2016
alert(A.new_member); // süleyman
alert(A.cds); // 2022
</script>
The Time Through Ages
In the Name of Allah, Most Gracious, Most Merciful
1. By the Time ,
2. Verily Man is in loss,
3. Except such as have Faith, and do righteous deeds, and (join together) in the mutual enjoining of Truth, and of Patience and Constancy.
Thank you for your reply. The "toSource()" doesn't work in IE.
Thank you again
Tom
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks