<p>The error is dependent on shell. In cmd (Windows) try:</p>
<pre><code>bitcoin-cli.exe -rpcwallet=test importdescriptors &quot;[{ \&quot;desc\&quot;: \&quot;pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)\&quot;, \&quot;timestamp\&quot;:1455191478, \&quot;internal\&quot;: true }]&quot;
</code></pre>
<p>It will not work the same with PowerShell.</p>
<p>In bash the dollar sign before the single quote may make difference (altough your initial command example works in Bash in my environment without the &quot;error: Error parsing JSON: [{&quot;):</p>
<pre><code>$ bitcoin-cli -rpcwallet=test importdescriptors $'[{ &quot;desc&quot;: &quot;pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)&quot;, &quot;timestamp&quot;:1455191478, &quot;internal&quot;: true }]'
</code></pre>

CC BY-SA 4.0
2023-02-15T21:32:52.113Z
OP is using a bash or similar shell, I believe.
Pieter Wuille
CC BY-SA 4.0
2023-02-15T20:17:10.603Z
2023-02-16T11:29:49.053Z
2023-02-16T11:29:49.053Z
Greg Tonoski
<p>I am trying to import a descriptor into a blank wallet but I get a JSON parsing error.</p>
<pre><code>$ cli createwallet &quot;test&quot; false true &quot;&quot; false true
$ cli -rpcwallet=test importdescriptors '[{ &quot;desc&quot;: &quot;pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)&quot;, &quot;timestamp&quot;:1455191478, &quot;internal&quot;: true }]'
error: Error parsing JSON: [{
</code></pre>
<p>Isn't the command <code>importdescriptors</code> expecting a JSON string?
I can't see why I get this error. By the way this is an example from <a href="https://developer.bitcoin.org/reference/rpc/importdescriptors.html" rel="nofollow noreferrer">https://developer.bitcoin.org/reference/rpc/importdescriptors.html</a></p>
<p>Edit1.</p>
<p>The argument is a correct JSON string</p>
<pre><code>$ export ARGS='[{ &quot;desc&quot;: &quot;pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)&quot;, &quot;timestamp&quot;:1455191478, &quot;internal&quot;: true }]'
$ echo $ARGS | jq
[
  {
    &quot;desc&quot;: &quot;pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)&quot;,
    &quot;timestamp&quot;: 1455191478,
    &quot;internal&quot;: true
  }
]
$ cli -rpcwallet=test importdescriptors $ARGS
error: Error parsing JSON: [{
</code></pre>
<p>I also tried changing single quotes with double quotes</p>
<pre><code>$ export ARGS2=&quot;[{ \&quot;desc\&quot;: \&quot;pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)\&quot;, \&quot;timestamp\&quot;:1455191478, \&quot;internal\&quot;: true }]&quot;
$ echo $ARGS2 | jq
[
  {
    &quot;desc&quot;: &quot;pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)&quot;,
    &quot;timestamp&quot;: 1455191478,
    &quot;internal&quot;: true
  }
]
$ cli -rpcwallet=test importdescriptors $ARGS2 
error: Error parsing JSON: [{
</code></pre>
<p>I am using a bash shell.</p>
<p>Edit2.</p>
<p>As suggested by @andrew-chow, removing the spaces solves the JSON parsing error,
this is weird. I tried a simple C++ application in my bash shell that reads arguments from the command line and anything inside single or double quotes is interpreted as a single string argument independently of spaces.</p>
<pre><code>int main(int nargs, char** args)
</code></pre>

CC BY-SA 4.0
2023-02-15T17:47:20.443Z
Try removing spaces in your json string.
Ava Chow
CC BY-SA 4.0
2023-02-15T17:54:06.657Z
`importdescriptors` is expecting a JSON string, and I was able to copy/paste your example and get a result (although, your example is missing a checksum and will result in an error). Are you sure you aren't missing a closing single quote?
josie
<json-rpc><output-script-descriptors>
How to import a descriptor into a wallet?
Lepus Cyberneticus
# How to import a descriptor into a wallet?

(Asked by: username_0 on 2023-02-15)

I am trying to import a descriptor into a blank wallet but I get a JSON parsing error.
$ cli createwallet "test" false true "" false true
$ cli -rpcwallet=test importdescriptors '[{ "desc": "pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)", "timestamp":1455191478, "internal": true }]'
error: Error parsing JSON: [{

Isn't the command importdescriptors expecting a JSON string?
I can't see why I get this error. By the way this is an example from https://developer.bitcoin.org/reference/rpc/importdescriptors.html
Edit1.
The argument is a correct JSON string
$ export ARGS='[{ "desc": "pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)", "timestamp":1455191478, "internal": true }]'
$ echo $ARGS | jq
[
  {
    "desc": "pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)",
    "timestamp": 1455191478,
    "internal": true
  }
]
$ cli -rpcwallet=test importdescriptors $ARGS
error: Error parsing JSON: [{

I also tried changing single quotes with double quotes
$ export ARGS2="[{ \"desc\": \"pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)\", \"timestamp\":1455191478, \"internal\": true }]"
$ echo $ARGS2 | jq
[
  {
    "desc": "pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)",
    "timestamp": 1455191478,
    "internal": true
  }
]
$ cli -rpcwallet=test importdescriptors $ARGS2 
error: Error parsing JSON: [{

I am using a bash shell.
Edit2.
As suggested by @andrew-chow, removing the spaces solves the JSON parsing error,
this is weird. I tried a simple C++ application in my bash shell that reads arguments from the command line and anything inside single or double quotes is interpreted as a single string argument independently of spaces.
int main(int nargs, char** args)

**Tags:** json-rpc, output-script-descriptors

> **Comments:**
> **username_1**: Try removing spaces in your json string.  
> **username_2**: `importdescriptors` is expecting a JSON string, and I was able to copy/paste your example and get a result (although, your example is missing a checksum and will result in an error). Are you sure you aren't missing a closing single quote?  

---

## 1 answers

### Answer by username_3 on 2023-02-15. Score: 0

The error is dependent on shell. In cmd (Windows) try:
bitcoin-cli.exe -rpcwallet=test importdescriptors "[{ \"desc\": \"pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)\", \"timestamp\":1455191478, \"internal\": true }]"

It will not work the same with PowerShell.
In bash the dollar sign before the single quote may make difference (altough your initial command example works in Bash in my environment without the "error: Error parsing JSON: [{"):
$ bitcoin-cli -rpcwallet=test importdescriptors $'[{ "desc": "pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)", "timestamp":1455191478, "internal": true }]'

> **Comments:**
> **username_4**: OP is using a bash or similar shell, I believe.  

---

