473,666 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JSON string not recognised by LMS

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.to String();
fScormSetValue( "cmi.suspend_da ta", tmp.toJSONStrin g(), false);
alas the LMS complains with this error
Error: missing ; before statement

Line: 1104, Column: 35
Source Code:
this.cmi.suspen d_data.cmivalue
= "{"assess":{"0_ 1q":true},"loc" :"res_0_2.htm", "progress":"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
Dec 18 '07 #1
7 2496
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.to String();
fScormSetValue( "cmi.suspend_da ta", tmp.toJSONStrin g(), false);
alas the LMS complains with this error
Error: missing ; before statement

Line: 1104, Column: 35
Source Code:
this.cmi.suspen d_data.cmivalue
= "{"assess":{"0_ 1q":true},"loc" :"res_0_2.htm", "progress":"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.suspen d_data.cmivalue ='{"assess":{"0 _1q":true},"loc ":"res_0_2.htm" ,"progress":"1" }';

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 18 '07 #2
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.to String();
fScormSetValue ("cmi.suspend_d ata", tmp.toJSONStrin g(), false);
alas the LMS complains with this error
Error: missing ; before statement

Line: 1104, Column: 35
Source Code:
this.cmi.suspe nd_data.cmivalu e
= "{"assess":{"0_ 1q":true},"loc" :"res_0_2.htm", "progress":"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.suspen d_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.toJSONStrin g().

Andrew Poulos
Dec 18 '07 #3
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.progres s = notes.topics.to String();
fScormSetValu e("cmi.suspend_ data", tmp.toJSONStrin g(), false);
alas the LMS complains with this error
Error: missing ; before statement

Line: 1104, Column: 35
Source Code:
this.cmi.susp end_data.cmival ue
= "{"assess":{"0_ 1q":true},"loc" :"res_0_2.htm", "progress":"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.suspe nd_data.cmivalu e='{"assess":{" 0_1q":true},"lo c":"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.toJSONStrin g().
I just tried this
mphLMS.scormSet Value("cmi.susp end_data","'"+t mp.toJSONString ()+"'",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.suspen d_data.cmivalue
="'{"assess":{" 0_1q":true},"lo c":"res_0_2.htm ","progress":"1 "}'";
------^

It looks like the LMS is wrapping the value I send in double quotes.

Andrew Poulos
Dec 18 '07 #4
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.progre ss = notes.topics.to String();
fScormSetVal ue("cmi.suspend _data", tmp.toJSONStrin g(), false);
alas the LMS complains with this error
Error: missing ; before statement

Line: 1104, Column: 35
Source Code:
this.cmi.sus pend_data.cmiva lue
= "{"assess":{"0_ 1q":true},"loc" :"res_0_2.htm", "progress":"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.susp end_data.cmival ue='{"assess":{ "0_1q":true},"l oc":"res_0_2.ht m","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.suspenda ta with the value tmp.toJSONStrin g().
I just tried this
mphLMS.scormSet Value("cmi.susp end_data","'"+t mp.toJSONString ()+"'",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.suspen d_data.cmivalue
="'{"assess":{" 0_1q":true},"lo c":"res_0_2.htm ","progress":"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.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 18 '07 #5
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.asses s = assessScore;
tmp.loc = location;
tmp.progres s = notes.topics.to String();
fScormSetVa lue("cmi.suspen d_data", tmp.toJSONStrin g(), false);
>
>
alas the LMS complains with this error
>
>
Error: missing ; before statement
>
Line: 1104, Column: 35
Source Code:
this.cmi.su spend_data.cmiv alue
= "{"assess":{"0_ 1q":true},"loc" :"res_0_2.htm", "progress":"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.sus pend_data.cmiva lue='{"assess": {"0_1q":true}," loc":"res_0_2.h tm","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.suspendat a with the value tmp.toJSONStrin g().
I just tried this
mphLMS.scormSe tValue("cmi.sus pend_data","'"+ tmp.toJSONStrin g()+"'",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.suspe nd_data.cmivalu e
="'{"assess":{ "0_1q":true},"l oc":"res_0_2.ht m","progress":" 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.to String();

var str = tmp.toJSONStrin g();

str = str.replace(/'/g, "'");
str = str.replace(/\"/g, "'");

fScormSetValue( "cmi.suspend_da ta", 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


Dec 19 '07 #6
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.to String();

var str = tmp.toJSONStrin g();

str = str.replace(/'/g, "'");
str = str.replace(/\"/g, "'");

fScormSetValue( "cmi.suspend_da ta", 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.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 19 '07 #7
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.to String();

var str = tmp.toJSONStrin g();

str = str.replace(/'/g, "'");
str = str.replace(/\"/g, "'");

fScormSetValue ("cmi.suspend_d ata", 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
Dec 19 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
6848
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... PS i am ready to use JSON as data/object interchange when using AJAX and my J2EE project - because it is easier to traverse the JavaScript object than its XML representation (so of course may argue).
2
3744
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 considered bad practice because it can disrupt the use of for in loops on Objects. Am I incorrect? Thanks,
3
10170
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); alert(json.glossary.title); for (var x in json) { console.log(x); alert(x.title); } This will show me the json object in the console with glossary and title underneath it. When the alert for json.glossary.title fires, it
1
1648
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 and here is what prints out: key is: tmp1, value is: tmp1; key is: tmp2, value is: tmp2; key is: tmp3, value is: tmp3; key is: toJSONstring, value is: function () { var a = , b,
1
2290
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 would like to read the JSON string sent from the client on the
23
3195
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 an object.
7
3043
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 . Putting the JSON into a foreach loop DOES access the member: foreach($json as $key=>$value) {
9
10866
by: Jon Paal [MSMD] | last post by:
using json like ( {"Records": , "RecordCount":"1" } ) and jquery like: $.ajax({ .... success: function(json, status) {
0
5370
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 you an example of how an data class (actually, a list of PHP documentation pages) might be represented, first in XML. and then in JSON. This side-by-side comparison should let you begin to understand how to represent data in JSON. The XML version:...
0
8444
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.