# Pavlovia error while saving data

**URL:** <https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087>\
**Category:** Online experiments\
**Tags:** labjs\
**Created:** [May 6, 2020, 6:22pm UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087 "2020-05-06T18:22:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![felixhenninger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/felixhenninger/32/8325_2.png) [@felixhenninger](https://discourse.psychopy.org/u/felixhenninger)\
**Post date:** [May 6, 2020, 6:22pm UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/1 "2020-05-06T18:22:44Z")

</div>

Dear all,

I am running into an issue at the end of experiments built with `lab.js` – Pavlovia’s integration appears to be failing, and loses all experimental data. This is observable with arbitrary experiments, that run fine on other platforms. Here’s the error message:

> ### [labjs-pavlovia plugin 3.2.5] Error
> 
> - when uploading participant’ results for experiment: felixhenninger/stroop-demo
> - when saving data from a previously opened session on the server
> - **unable to JSON decode the value: Expecting value: line 1 column 1 (char 0)**

It looks like the server infrastructure is expecting a different data format from the one that the Pavlovia JS plugin is sending?

Any hints would be much appreciated. Many thanks,

-Felix

---

<div class="post-metadata">

**Author:** ![felixhenninger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/felixhenninger/32/8325_2.png) [@felixhenninger](https://discourse.psychopy.org/u/felixhenninger)\
**Post date:** [May 6, 2020, 6:26pm UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/2 "2020-05-06T18:26:41Z")

</div>

(also, for the record, the value _is_ JSON-encoded, as filename/contents pair)

---

<div class="post-metadata">

**Author:** ![felixhenninger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/felixhenninger/32/8325_2.png) [@felixhenninger](https://discourse.psychopy.org/u/felixhenninger)\
**Post date:** [May 8, 2020, 11:24am UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/3 "2020-05-08T11:24:50Z")

</div>

@apitiot could you kindly take a look at this? Many thanks -Felix

---

<div class="post-metadata">

**Author:** ![apitiot](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@apitiot](https://discourse.psychopy.org/u/apitiot)\
**Post date:** [May 18, 2020, 8:33am UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/4 "2020-05-18T08:33:23Z")

</div>

Hello @felixhenninger,

The issue here is that lab.js experiment produce results that are not in JSON format and, consequently, cannot be saved in the database.

If you change the Saving Format of your experiment to CSV, rather than DATABASE, you should be able to save your results. Certainly it works on my end.

I have modified the [pavlovia.org](http://pavlovia.org) front end to warn experiment designers when they change the saving format to DATABASE for experiments labelled as lab.js one that there will be an issue with the saving of results. I have also updated the documentation and added a warning at [https://pavlovia.org/docs/experiments/create-labjs:](https://pavlovia.org/docs/experiments/create-labjs:)

“Note that lab.js experiments should use `CSV` as **Saving Format** : it is not possible to save lab.js results in the database.”

Alain

---

<div class="post-metadata">

**Author:** ![felixhenninger](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/felixhenninger/32/8325_2.png) [@felixhenninger](https://discourse.psychopy.org/u/felixhenninger)\
**Post date:** [July 20, 2020, 2:31pm UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/5 "2020-07-20T14:31:39Z")

</div>

Hej @apitiot, and thanks for your reply! (apologies also for the late follow-up)

From a `lab.js` perspective, we can provide both CSV and JSON outputs of experimental data, and the choice of format is yours to make in the Pavlovia plugin. Specifically, on line 60 of the [Pavlovia plugin](https://run.pavlovia.org/felixhenninger/stroop-demo/lib/labjs-pavlovia-3.2.5.js), the command reads `context.options.datastore.exportCsv()`; if you change that to `exportJson()`, you’ll get raw JSON-encoded data.

I hope that makes sense, and would love to help you make the change – from what I can tell, that’s all that needs to be changed, but I couldn’t find a place to submit a pull request 🙂 .

Please let me know if I can be of any assistance in this, I’d be glad to! Kind regards, and keep up the great work,

-Felix

---

<div class="post-metadata">

**Author:** ![apitiot](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@apitiot](https://discourse.psychopy.org/u/apitiot)\
**Post date:** [August 4, 2020, 9:56am UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/6 "2020-08-04T09:56:59Z")

</div>

Hello @felixhenninger,

Thank you for the tip!  
I’ve just updated the latest version of the plugin: 2020.2 to make it possible to save to either a .csv file and into the database.  
Would you like to give it a whirl?

Incidentally, is it possible for me to get the session name (if there is one) and the participant name (if there is one). At the moment I use: SESSION, and PARTICIPANT. Any thoughts on the matter?

Alain

---

<div class="post-metadata">

**Author:** ![Prisca\_Han](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/prisca_han/32/9901_2.png) [@Prisca\_Han](https://discourse.psychopy.org/u/Prisca_Han)\
**Post date:** [August 4, 2020, 10:13am UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/7 "2020-08-04T10:13:19Z")

</div>

Hi @apitiot,

I’m currently trying to deploy my lab.js experiment on Pavlovia and had a few questions regarding data capture in GitLab. I’ve followed the Pavlovia documentation and made edits to my html & javascript code - but is it the case that we can only have data saved on the server and automatically uploaded to GitLab when the experiment is in “run” versus “pilot” mode (I’m currently awaiting approval for run status so unsure if the data will be captured)?

I also wanted to remove the option for participants to download their data on their local machine and have the experiment end and automatically capture their data, is the documentation as per the Stroop example the best way to go about this ([https://pavlovia.org/docs/experiments/create-labjs](https://pavlovia.org/docs/experiments/create-labjs) )? Thanks for your help! 🙂

---

<div class="post-metadata">

**Author:** ![jon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jon/32/22_2.png) [@jon](https://discourse.psychopy.org/u/jon)\
**Post date:** [August 4, 2020, 11:03am UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/8 "2020-08-04T11:03:03Z")

</div>

@Prisca_Han The change to the data being saved automatically is what happens in run mode rather than pilot mode

---

<div class="post-metadata">

**Author:** ![Prisca\_Han](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/prisca_han/32/9901_2.png) [@Prisca\_Han](https://discourse.psychopy.org/u/Prisca_Han)\
**Post date:** [August 5, 2020, 7:54am UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/9 "2020-08-05T07:54:18Z")

</div>

Thanks @jon!

---

<div class="post-metadata">

**Author:** ![F\_Elisabeth](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/f_elisabeth/32/9370_2.png) [@F\_Elisabeth](https://discourse.psychopy.org/u/F_Elisabeth)\
**Post date:** [August 26, 2020, 1:05pm UTC](https://discourse.psychopy.org/t/pavlovia-error-while-saving-data/13087/10 "2020-08-26T13:05:18Z")

</div>

Hi @jon,

Is that possible for a jsPsych experiment to save data with json format on pavlovia ? Because I made some debrief trials as the one on the tutorial but when I save the csv file just put [object Object] to these lines and I don’t know how to make it correct for csv.
