adds dataAsJSON (#212)

This commit is contained in:
Josh de Leeuw 2016-01-05 11:34:53 -05:00
parent 4ce36b8460
commit 9a9b7bba7a
4 changed files with 30 additions and 0 deletions

View File

@ -3,6 +3,7 @@ The following people have contributed to the development of jsPsych by writing c
* Josh de Leeuw - https://github.com/jodeleeuw
* Jonas Lambers
* Shane Martin - https://github.com/shamrt
* Adrian Oesch - https://github.com/adrianoesch
* Marian Sauter - https://github.com/mariansauter
* Tim Vergenz - https://github.com/vergenzt
* Erik Weitnauer - https://github.com/eweitnauer

View File

@ -97,6 +97,29 @@ Generate a CSV formatted string containing all of the data generated in the expe
var csvString = jsPsych.data.dataAsCSV();
```
---
## jsPsych.data.dataAsJSON
```
jsPsych.data.dataAsJSON()
```
### Return value
Returns a string in JSON format
### Description
Generate a JSON formatted string containing all of the data generated in the experiment.
### Examples
#### Basic example
```javascript
var jsonString = jsPsych.data.dataAsJSON();
```
---
## jsPsych.data.displayData

View File

@ -24,6 +24,7 @@ Every jsPsych experiment utilizes the core library (contained in the `jspsych.js
* [jsPsych.data.addDataToLastTrial](jspsych-data.md#jspsychdataadddatatolasttrial)
* [jsPsych.data.addProperties](jspsych-data.md#jspsychdataaddproperties)
* [jsPsych.data.dataAsCSV](jspsych-data.md#jspsychdatadataascsv)
* [jsPsych.data.dataAsJSON](jspsych-data.md#jspsychdatadataasjson)
* [jsPsych.data.displayData](jspsych-data.md#jspsychdatadisplaydata)
* [jsPsych.data.getData](jspsych-data.md#jspsychdatagetdata)
* [jsPsych.data.getLastChunkData](jspsych-data.md#jspsychdatagetlastchunkdata)

View File

@ -645,6 +645,11 @@ jsPsych.data = (function() {
return JSON2CSV(dataObj);
};
module.dataAsJSON = function() {
var dataObj = module.getData();
return JSON.stringify(dataObj);
};
module.localSave = function(filename, format) {
var data_string;