How do I export all node information to JSON

I’m trying to build a plugin that can save all node data of the user’s selection, and export it to JSON that can be decoded later back to Figma nodes. I found a Figma to JSON decoder and encoder but it doesn’t work for me, and I’d love to try it myself.