user42482: Using bitcoinjs you can generate a keyPair with the following code:
var keyPair = bitcoin.ECPair.makeRandom();

How can I stringify this object to JSON and then parse it back to an object? JSON doesn't play well with circular objects and I'm struggling to understand how one can work around this. 
Thanks,
Connor

user3115: Wallet Import Format can be used in a Javascript String,  which is JSON compatible.
For bitcoinjs-lib@^2.0.0:

var prv = keyPair.toWIF()

To recover, use

bitcoin.ECPair.fromWIF(prv)

Caution: if you store your private key in an insecure location, your funds will be insecure. fromWIF/toWIF does not provide any form 
of protection.

42482: <p>Using bitcoinjs you can generate a keyPair with the following code:</p>

<pre><code>var keyPair = bitcoin.ECPair.makeRandom();
</code></pre>

<p>How can I stringify this object to JSON and then parse it back to an object? JSON doesn't play well with circular objects and I'm struggling to understand how one can work around this. </p>

<p>Thanks,</p>

<p>Connor</p>
 3115: <p><a href="https://en.bitcoin.it/wiki/Wallet_import_format" rel="nofollow noreferrer">Wallet Import Format</a> can be used in a Javascript <code>String</code>,  which is JSON compatible.
For <code>bitcoinjs-lib@^2.0.0</code>:</p>

<blockquote>
  <p>var prv = keyPair.toWIF()</p>
</blockquote>

<p>To recover, use</p>

<blockquote>
  <p>bitcoin.ECPair.fromWIF(prv)</p>
</blockquote>

<p><strong>Caution</strong>: if you store your private key in an insecure location, your funds will be insecure. <code>fromWIF/toWIF</code> <strong><em>does not provide any form 
of protection.</em></strong></p>
