<p>JSON data structure supports lists (arrays).</p>

<ul>
<li><a href="http://en.wikipedia.org/wiki/JSON" rel="nofollow">http://en.wikipedia.org/wiki/JSON</a></li>
</ul>

<p>In the first API command (ListAccounts) the result contents is an object which contains a string.  Inside this string is a set of data records, each of which is a key/value item.  </p>

<p>In the second (ListReceivedByAccount) the result contents is an array of objects, each of which holds account data.</p>

<p>That does appear inconsistent, where perhaps the first call should have returned an array as well.</p>

<p>However a rule of thumb is that existing APIs should not change.  They can be deprecated and replaced but a call is expected to behave in a consistent manner.  </p>

<p>The Bitcoin client is an open source project and thus an issue ticket for this inconsistency can be opened and a pull request with the source for a new API call submitted.  Whether such an issue is merged into the client depends on a number of factors, including severity of problem.</p>

CC BY-SA 3.0
2012-12-16T22:31:14.243Z
Personally, I doubt a simple data structure inconsistency would get adopted, but if the ListAccounts API call ever does need revision it is likely the replacement call (again, under a different name) would incorporate the change so this inconsistency no longer exists.
Stephen Gornick
CC BY-SA 3.0
2012-12-16T22:58:21.747Z
Part of my question is, the outer most "id" element... is that some kind of versioning for the API.. all json results have that as "1".  Perhaps a new version of the array or newly added types should return "2"? no?
makerofthings7
CC BY-SA 3.0
2012-12-17T00:07:43.517Z
That id is the same one as your client sent. JSON-RPC answers just mirror the request id.
Pieter Wuille
CC BY-SA 3.0
2012-12-16T22:14:30.867Z
2012-12-25T12:40:25.570Z
2012-12-25T12:40:25.570Z
Stephen Gornick
<p>When I perform a ListAccounts query I get this:</p>

<pre><code>  {
  "result": {
    "": 0.0,
    "account": 0.0,
    "account3": 0.0,
    "account7": 0.0
  },
  "error": null,
  "id": "1"
}
</code></pre>

<p>However ListReceivedByAccount(0, true); looks like this:</p>

<pre><code>  {
   "result": [
     {
       "account": "",
       "amount": 0.0,
       "confirmations": 0
     },
     {
       "account": "account",
       "amount": 0.0,
       "confirmations": 0
     },
     {
       "account": "account3",
       "amount": 0.0,
       "confirmations": 0
     },
     {
       "account": "account7",
       "amount": 0.0,
       "confirmations": 0
     }
   ],
   "error": null,
   "id": "1"
</code></pre>

<p>Notice how the embedded array data is formatted differently?  Is there a name or term that describes these different array formats (named vs unnamed)?</p>

<p>Why is it different and can this be fixed in a future version? </p>

<p>If it is fixed in a future version will the outermost "id" property become "2" so I can add the logic to my parsers?</p>

CC BY-SA 3.0
2012-12-16T22:34:25.507Z
I initially voted to close this thinking it was off-topic (askng about JSON data types) but it is specific enough to bitcoin that I would withdraw that vote if I could.
Stephen Gornick
CC BY-SA 3.0
2012-12-16T22:57:15.787Z
@StephenGornick I made an edit so you can remove the downvote..
makerofthings7
<development><json-rpc>
ListAccounts JSON array data isn't consistently formatted (compared to ListReceivedByAccount)
makerofthings7
# ListAccounts JSON array data isn't consistently formatted (compared to ListReceivedByAccount)

(Asked by: username_0 on 2012-12-16)

When I perform a ListAccounts query I get this:

```
  {
  "result": {
    "": 0.0,
    "account": 0.0,
    "account3": 0.0,
    "account7": 0.0
  },
  "error": null,
  "id": "1"
}

```

However ListReceivedByAccount(0, true); looks like this:

```
  {
   "result": [
     {
       "account": "",
       "amount": 0.0,
       "confirmations": 0
     },
     {
       "account": "account",
       "amount": 0.0,
       "confirmations": 0
     },
     {
       "account": "account3",
       "amount": 0.0,
       "confirmations": 0
     },
     {
       "account": "account7",
       "amount": 0.0,
       "confirmations": 0
     }
   ],
   "error": null,
   "id": "1"

```

Notice how the embedded array data is formatted differently? Is there a name or term that describes these different array formats (named vs unnamed)?

Why is it different and can this be fixed in a future version?

If it is fixed in a future version will the outermost "id" property become "2" so I can add the logic to my parsers?

**Tags:** development, json-rpc

> **Comments:**
> **username_1**: I initially voted to close this thinking it was off-topic (askng about JSON data types) but it is specific enough to bitcoin that I would withdraw that vote if I could.  
> **username_0**: @username_1 I made an edit so you can remove the downvote..  

---

## 1 answers

### Answer by username_1 on 2012-12-16. Score: 1 | Accepted answer

JSON data structure supports lists (arrays).

* <http://en.wikipedia.org/wiki/JSON>

In the first API command (ListAccounts) the result contents is an object which contains a string. Inside this string is a set of data records, each of which is a key/value item.

In the second (ListReceivedByAccount) the result contents is an array of objects, each of which holds account data.

That does appear inconsistent, where perhaps the first call should have returned an array as well.

However a rule of thumb is that existing APIs should not change. They can be deprecated and replaced but a call is expected to behave in a consistent manner.

The Bitcoin client is an open source project and thus an issue ticket for this inconsistency can be opened and a pull request with the source for a new API call submitted. Whether such an issue is merged into the client depends on a number of factors, including severity of problem.

> **Comments:**
> **username_1**: Personally, I doubt a simple data structure inconsistency would get adopted, but if the ListAccounts API call ever does need revision it is likely the replacement call (again, under a different name) would incorporate the change so this inconsistency no longer exists.  
> **username_0**: Part of my question is, the outer most "id" element... is that some kind of versioning for the API.. all json results have that as "1".  Perhaps a new version of the array or newly added types should return "2"? no?  
> **username_2**: That id is the same one as your client sent. JSON-RPC answers just mirror the request id.  

---

