I am having redux store
as object key value
pairs as given below:
{
"appElements": {
"layers": {
"layer_1": {
"scene": {
"width": "100px",
"height": "100px",
"bgColor": "#aaaaaa",
"bgImage": "http:bgimage1.png"
},
"items": {
"yrgroih9": {
"width": "100px",
"x": "200px"
},
"qhy0dukj": {
"width": "100px",
"x": "200px"
},
"7lw2nvma": {
"width": "100px",
"x": "200px"
}
}
}
}
}
}
I am using Immutable Js and the above data stored as Immutable Map
data type into store.
Below image shows the state structure for better understanding:
I need to save the above given store values into external json file, for example mysavedfile.json
.
Code used in react reducer:
import { Map, fromJS, isImmutable } from 'immutable';
export default function images(state = new Map(), action) {
switch (action.type) {
case 'ADD_LAYERS':
return fromJS({ appElements:action.data.appElements });
case 'STATE_TO_JSON_FILE':
console.log("state");
//Here i need to do code to save state to external json file.
default:
return state
}
}
How to achieve this..?