Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31548
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!news.glorb.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!nntp.westnet.com.au!news.westnet.com.au.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Sun, 09 Oct 2016 18:47:56 -0500 |
| Subject | Re: String concat with JSON |
| Newsgroups | comp.lang.javascript |
| References | <4eKdnfDJCYfNS2fKnZ2dnUU7-YXNnZ2d@westnet.com.au> |
| From | Andrew Poulos <ap_prog@hotmail.com> |
| Date | Mon, 10 Oct 2016 10:47:57 +1100 |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
| MIME-Version | 1.0 |
| In-Reply-To | <4eKdnfDJCYfNS2fKnZ2dnUU7-YXNnZ2d@westnet.com.au> |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Message-ID | <4eKdnfPJCYexSmfKnZ2dnUU7-YWdnZ2d@westnet.com.au> (permalink) |
| Lines | 42 |
| X-Usenet-Provider | http://www.giganews.com |
| NNTP-Posting-Host | 106.69.219.67 |
| X-Trace | sv3-XRuamGkxqoBuyIQTdSWuKRfc2iloXiT52YJepMJwXfBwpZ8EMdG4/q4uGOiGnstToy0Vf8BSNWRuJ7S!XX/oi9Hyyn4riVX2xMRFWXCFMUdUX+OVfUQpEmBa9bFFCAlSDU48BDFFcDFEtp4bRD0X23ilf1rw!X/0qJPlLw/JNMZfQngHW |
| X-Complaints-To | abuse@westnet.com.au |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 2598 |
| X-Received-Bytes | 2689 |
| X-Received-Body-CRC | 2757498601 |
| Xref | csiph.com comp.lang.javascript:31548 |
Show key headers only | View raw
On 10/10/2016 10:44 AM, Andrew Poulos wrote:
> I'm trying to communicate between the elearning piece I'm building and
> the learning management system (LMS).
>
> The elearning creates a separate JSON string for each section but the
> LMS stores them all in the same place in whatever order it decides is
> appropriate. To be able to identify them correctly I'm appending
> "Page_1=", "Page_2=", "Page_3="... to each JSON string. (I'm going to
> read back the entire string and then split it on "Page_x=" and then
> JSON.parse it.)
>
> With a simple test
>
> var tmp = JSON.stringify(currentPageData);
> // currentPageData is a one dim array with strings for elements
> LMSSetValue("cmi.comments", "Page_1=" + tmp);
>
> The LMS complains thus
>
> Exception:
> SyntaxError: Unexpected identifier at LMSSetValueMethod
>
> The relevant bits of the LMS code (over which I have no control) are
>
> setString = "this." + element + ".cmivalue =\"" + value + "\";";
> var result = eval(setString);
>
> It's trying to set value as "Page_1=["Test Data"]"
>
> Why does adding a string to a JSON string give me an invalid string?
>
> How do I get a valid string?
I just ran another test without adding the string
var tmp = JSON.stringify(currentPageData);
LMSSetValue("cmi.comments", tmp);
and it gives the same error with the value as "["Test Data"]"
Andrew Poulos
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
String concat with JSON Andrew Poulos <ap_prog@hotmail.com> - 2016-10-10 10:44 +1100 Re: String concat with JSON Andrew Poulos <ap_prog@hotmail.com> - 2016-10-10 10:47 +1100 Re: String concat with JSON Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-10-10 12:35 +0100
csiph-web