I'm creating a JSON string and passing it to a SCORM 1.2 compliant LMS thus:
var tmp = {};
tmp.assess = assessScore;
tmp.loc = location;
tmp.progress = notes.topics.toString();
fScormSetValue("cmi.suspend_data", tmp.toJSONString(), false);
alas the LMS complains with this error
Error: missing ; before statement
Line: 1104, Column: 35
Source Code:
this.cmi.suspend_data.cmivalue
= "{"assess":{"0_1q":true},"loc":"res_0_2.htm","prog ress":"1"}";
------^
Ok, the LMS sees the JSON string as more than one string. I can, though,
successfully read and write it to a cookie.
I'm not sure what's going on. How do I resolve this?
Andrew Poulos 7 2474
Andrew Poulos said the following on 12/18/2007 1:32 AM:
I'm creating a JSON string and passing it to a SCORM 1.2 compliant LMS
thus:
var tmp = {};
tmp.assess = assessScore;
tmp.loc = location;
tmp.progress = notes.topics.toString();
fScormSetValue("cmi.suspend_data", tmp.toJSONString(), false);
alas the LMS complains with this error
Error: missing ; before statement
Line: 1104, Column: 35
Source Code:
this.cmi.suspend_data.cmivalue
= "{"assess":{"0_1q":true},"loc":"res_0_2.htm","prog ress":"1"}";
------^
The first guess would that your problem is a quoting issue where it is
seeing the "{" and then assess and balking on the quotes. Try changing
the outer quotes to ' and see if it makes a difference.
this.cmi.suspend_data.cmivalue='{"assess":{"0_1q": true},"loc":"res_0_2.htm","progress":"1"}';
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
Andrew Poulos said the following on 12/18/2007 1:32 AM:
>I'm creating a JSON string and passing it to a SCORM 1.2 compliant LMS thus:
var tmp = {}; tmp.assess = assessScore; tmp.loc = location; tmp.progress = notes.topics.toString(); fScormSetValue("cmi.suspend_data", tmp.toJSONString(), false);
alas the LMS complains with this error
Error: missing ; before statement
Line: 1104, Column: 35 Source Code: this.cmi.suspend_data.cmivalue = "{"assess":{"0_1q":true},"loc":"res_0_2.htm","prog ress":"1"}"; ------^
The first guess would that your problem is a quoting issue where it is
seeing the "{" and then assess and baulking on the quotes. Try changing
the outer quotes to ' and see if it makes a difference.
this.cmi.suspend_data.cmivalue='{"assess":{"0_1q": true},"loc":"res_0_2.htm","progress":"1"}';
The error is being produced/reported by the LMS and is not something I
can edit. I call fScormSetValue which tells the LMS to update
cmi.suspendata with the value tmp.toJSONString().
Andrew Poulos
Andrew Poulos wrote:
Randy Webb wrote:
>Andrew Poulos said the following on 12/18/2007 1:32 AM:
>>I'm creating a JSON string and passing it to a SCORM 1.2 compliant LMS thus:
var tmp = {}; tmp.assess = assessScore; tmp.loc = location; tmp.progress = notes.topics.toString(); fScormSetValue("cmi.suspend_data", tmp.toJSONString(), false);
alas the LMS complains with this error
Error: missing ; before statement
Line: 1104, Column: 35 Source Code: this.cmi.suspend_data.cmivalue = "{"assess":{"0_1q":true},"loc":"res_0_2.htm","prog ress":"1"}"; ------^
The first guess would that your problem is a quoting issue where it is seeing the "{" and then assess and baulking on the quotes. Try changing the outer quotes to ' and see if it makes a difference.
this.cmi.suspend_data.cmivalue='{"assess":{"0_1q" :true},"loc":"res_0_2.htm","progress":"1"}';
The error is being produced/reported by the LMS and is not something I
can edit. I call fScormSetValue which tells the LMS to update
cmi.suspendata with the value tmp.toJSONString().
I just tried this
mphLMS.scormSetValue("cmi.suspend_data","'"+tmp.to JSONString()+"'",false);
in a wishful thinking frame of mind and got this error from the LMS:
Error: missing ; before statement
Line: 1104, Column: 36
Source Code:
this.cmi.suspend_data.cmivalue
="'{"assess":{"0_1q":true},"loc":"res_0_2.htm","pr ogress":"1"}'";
------^
It looks like the LMS is wrapping the value I send in double quotes.
Andrew Poulos
Andrew Poulos said the following on 12/18/2007 6:07 AM:
Andrew Poulos wrote:
>Randy Webb wrote:
>>Andrew Poulos said the following on 12/18/2007 1:32 AM: I'm creating a JSON string and passing it to a SCORM 1.2 compliant LMS thus:
var tmp = {}; tmp.assess = assessScore; tmp.loc = location; tmp.progress = notes.topics.toString(); fScormSetValue("cmi.suspend_data", tmp.toJSONString(), false);
alas the LMS complains with this error
Error: missing ; before statement
Line: 1104, Column: 35 Source Code: this.cmi.suspend_data.cmivalue = "{"assess":{"0_1q":true},"loc":"res_0_2.htm","prog ress":"1"}"; ------^
The first guess would that your problem is a quoting issue where it is seeing the "{" and then assess and baulking on the quotes. Try changing the outer quotes to ' and see if it makes a difference.
this.cmi.suspend_data.cmivalue='{"assess":{"0_1q ":true},"loc":"res_0_2.htm","progress":"1"}'; The error is being produced/reported by the LMS and is not something I can edit. I call fScormSetValue which tells the LMS to update cmi.suspendata with the value tmp.toJSONString().
I just tried this
mphLMS.scormSetValue("cmi.suspend_data","'"+tmp.to JSONString()+"'",false);
in a wishful thinking frame of mind and got this error from the LMS:
Error: missing ; before statement
Line: 1104, Column: 36
Source Code:
this.cmi.suspend_data.cmivalue
="'{"assess":{"0_1q":true},"loc":"res_0_2.htm","pr ogress":"1"}'";
------^
It looks like the LMS is wrapping the value I send in double quotes.
Then you either have to use ' in your value, escape it in your value, or
encode it.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
Andrew Poulos said the following on 12/18/2007 6:07 AM:
>Andrew Poulos wrote:
>>Randy Webb wrote: Andrew Poulos said the following on 12/18/2007 1:32 AM: I'm creating a JSON string and passing it to a SCORM 1.2 compliant LMS thus: > var tmp = {}; tmp.assess = assessScore; tmp.loc = location; tmp.progress = notes.topics.toString(); fScormSetValue("cmi.suspend_data", tmp.toJSONString(), false); > > alas the LMS complains with this error > > Error: missing ; before statement > Line: 1104, Column: 35 Source Code: this.cmi.suspend_data.cmivalue = "{"assess":{"0_1q":true},"loc":"res_0_2.htm","prog ress":"1"}"; ------^
The first guess would that your problem is a quoting issue where it is seeing the "{" and then assess and baulking on the quotes. Try changing the outer quotes to ' and see if it makes a difference.
this.cmi.suspend_data.cmivalue='{"assess":{"0_1 q":true},"loc":"res_0_2.htm","progress":"1"}';
The error is being produced/reported by the LMS and is not something I can edit. I call fScormSetValue which tells the LMS to update cmi.suspendata with the value tmp.toJSONString().
I just tried this mphLMS.scormSetValue("cmi.suspend_data","'"+tmp.t oJSONString()+"'",false);
in a wishful thinking frame of mind and got this error from the LMS:
Error: missing ; before statement
Line: 1104, Column: 36 Source Code: this.cmi.suspend_data.cmivalue ="'{"assess":{"0_1q":true},"loc":"res_0_2.htm","p rogress":"1"}'"; ------^
It looks like the LMS is wrapping the value I send in double quotes.
Then you either have to use ' in your value, escape it in your value, or
encode it.
If I first convert apostrophes to ' and then quote to apostrophes
the LMS doesn't complain:
var tmp = {};
tmp.assess = assessScore;
tmp.loc = location;
tmp.progress = notes.topics.toString();
var str = tmp.toJSONString();
str = str.replace(/'/g, "'");
str = str.replace(/\"/g, "'");
fScormSetValue("cmi.suspend_data", str, false);
When I read back the value I reverse the process. It seems to be
working. Is this the "best" way to do it?
Andrew Poulos
Andrew Poulos said the following on 12/18/2007 8:53 PM:
Randy Webb wrote:
<snip>
>Then you either have to use ' in your value, escape it in your value, or encode it.
If I first convert apostrophes to ' and then quote to apostrophes
the LMS doesn't complain:
var tmp = {};
tmp.assess = assessScore;
tmp.loc = location;
tmp.progress = notes.topics.toString();
var str = tmp.toJSONString();
str = str.replace(/'/g, "'");
str = str.replace(/\"/g, "'");
fScormSetValue("cmi.suspend_data", str, false);
When I read back the value I reverse the process. It seems to be
working. Is this the "best" way to do it?
Without knowing how the LMS works, nobody can tell you what way would be
"best". The only thing you can do is try different ways and see which
ones don't fail. If it isn't broke, don't fix it though :)
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
Andrew Poulos said the following on 12/18/2007 8:53 PM:
>Randy Webb wrote:
<snip>
>>Then you either have to use ' in your value, escape it in your value, or encode it. If I first convert apostrophes to ' and then quote to apostrophes the LMS doesn't complain:
var tmp = {}; tmp.assess = assessScore; tmp.loc = location; tmp.progress = notes.topics.toString();
var str = tmp.toJSONString();
str = str.replace(/'/g, "'"); str = str.replace(/\"/g, "'");
fScormSetValue("cmi.suspend_data", str, false);
When I read back the value I reverse the process. It seems to be working. Is this the "best" way to do it?
Without knowing how the LMS works, nobody can tell you what way would be
"best". The only thing you can do is try different ways and see which
ones don't fail. If it isn't broke, don't fix it though :)
Alas the LMS is a 3rd party product and so not open to inspection.
Thanks for your help.
Andrew Poulos This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Luke Matuszewski |
last post by:
Welcome
As suggested i looked into JSON project and was amazed but...
What about cyclical data structures - anybody was faced it in some
project ?
Is there any satisactional recomendation...
...
|
by: Kevin Newman |
last post by:
Hello,
I noticed that the JavaScript library for JSON posted on json.org
(http://www.json.org/json.js) is modifying Object.prototype (adding a
method - toJSONString). I thought this was...
|
by: Adam |
last post by:
I'm trying to retrieve some values from a json object, but instead it's
giving me the property name. For example:
var json = { "glossary": { "title": "example glossary" } };
console.log(json);...
|
by: kungfumike |
last post by:
Currently having a problem getting JSON to include properly. I When I attempt to call .toJSONstring on an array it was giving me an error. So I resorted to just alerting the array out to the screen...
|
by: seth |
last post by:
Hi:
I'm trying to read JSON strings sent from the browser. Here is the
scenario:
1. Using YUI tookit
2. sending JSON string from YUI toolkit - using the provided
asyncRequest method.
**I...
|
by: dhtmlkitchen |
last post by:
JSON
We all know what it is.
In ECMAScript 4, there's a JSON proposal:
Object.prototype.toJSONString
String.prototype.parseJSON
The current proposal, String.prototype.parseJSON, returns...
|
by: Logos |
last post by:
I am using PHP with the JSON extension function json_decode.
I have a JSON with a member named "1" (ie) { "1":"somedata" }
Trying to access this via the -operator doesn't work, nor does
.
...
|
by: Jon Paal [MSMD] |
last post by:
using json like
( {"Records": , "RecordCount":"1" } )
and jquery like:
$.ajax({
....
success: function(json, status) {
|
by: crocodilu2008 |
last post by:
JSON vs. XML
JSON and XML are basically used for the same purpose—to represent and interchange data. I'll try to show you why you might want to use JSON rather than XML in an AJAX context by showing...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |