Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 31 to 36 of 36
08-10-2013, 10:36 PM #31
- Join Date
- Sep 2005
- Sydney, Australia
- Thanked 634 Times in 624 Posts
08-11-2013, 01:03 AM #32
Changed last post from:
/* this version does not seem to work for the "parse" part */ str = JSON.stringify(manifest); document.getElementById('debugDIV').innerHTML += '<p>'+str; // this line works ok alert( JSON.parse(str) ); // unexpected character error on this line /* */
/* this version does not seem to work for the "parse" part */ str = JSON.stringify(manifest); document.getElementById('debugDIV').innerHTML += '<p>'+str; // this line works ok alert( JSON.parse(manifest) ); // unexpected character error on this line /* */
In the first, the alert says [object Object].
On the second, there is no alert, but the error console reports
Timestamp: 8/10/2013 7:51:56 PM
Error: SyntaxError: JSON.parse: unexpected character
Source File: file:///C:/Users/Owner/Desktop/HTMLtest.html
and reloaded to be at a later time of by a different program.
Currently I am able to save the manifest string in a JSON format
but I don't see how it can be decoded to become active again as a variable.
08-11-2013, 01:06 AM #33
08-11-2013, 01:55 AM #34
Again, as Felgall said, to convert a network of objects to a string--the OPPOSITE action--you use JSON.stringify.
You do not NEED and do not WANT to use JSON.parse() for this...at all.
str = JSON.stringify(manifest); alert( str );
Last edited by Old Pedant; 08-11-2013 at 01:57 AM.An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
08-11-2013, 02:51 AM #35
- Join Date
- Jan 2013
- Thanked 0 Times in 0 Posts
for some reason your last variation on the equivalent code was easier for me to understand :
var str = manifest.a.filename + '\n' + manifest.a.aphorism + '\n' + manifest.a.dog;
as far as why don't i try watching a basic JS course on youtube, that makes me smile. i have downloaded and gone thru the JS courses and lessons from : the new boston, adam khoury, stephan mischook, derek banas, code academy, jream, tutor4u, some of w3schools sections, some parts of developer.mozilla, and 2 or 3 others that i don't remember because i recently deleted them for space. i have made DVD's of several series and watched them over and over (even played them while sleeping in hopes of absorption). and not just watched them, watched them on one screen and wrote and tested the code on another screen in notepad++ as i went along. but even having done all that, i don't blame you for thinking i am brand new at this. i am old at studying the subject, but a dunce at actually learning it.
however, those lessons (and 1 or 2 brilliant (to me anyway) tips from this forum months ago) have been enough for me to set up a working website, which uses a fair amount of JS, that i am proud of.
the reason i posted the question about terminology (Object, key, property, value) is that, the most ingenious part of my site, the part that was given to me here by xelawho in january, is the ONLY part i don't understand and didn't write myself. and i am beginning to believe that that tip is really at the center of what JS is all about, and i want to know it.
well, that was a lot of yakking wasn't it ?
Last edited by pratto; 08-11-2013 at 03:08 AM.
08-11-2013, 07:25 AM #36
- Join Date
- Aug 2013
- Thanked 11 Times in 11 Posts
I'm glad you want to learn, that's awesome.