converting immutable fromJS object back to json
Asked Answered
M

2

13

I want to be able to look at my immutable objects for debugging. I find it very difficult to look through an object by clicking on entries and such. Ideally what I would like is the opposite of the formJS function

so,

const immutableObj = fromJS({name: 'bob'})
return oppositeJS(immutableObj)  
=> {name: 'bob'}
Myalgia answered 10/2, 2016 at 19:59 Comment(0)
M
24

nevermind, I found it in the documentation

toJS()
Myalgia answered 10/2, 2016 at 20:0 Comment(2)
As a side note, I had the same issue debugging Immutable.js data structures and created this little helper for Chrome github.com/danielepolencic/immutablejs-devtoolsLeveille
Btw, their is also toJSON in immutable, it's pretty much just an alias but if you wanted to be explicit about the type your expecting (namely JSON) I would use that.Pindling
S
2

Just use toJS() To read more about https://devdocs.io/immutable/index#map.tojs

const immutableObj = fromJS({name: 'bob'})

const backToObj = immutableObj.toJS();
Stroke answered 5/5, 2021 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.