Json object getting converted to an array

I am running a web server application using node.js and javascript. I am writing json to the couchbase server using upsert to the openBucket. All works well except I have as part of my json structure
{test : {“1” : {“name”, “a”}, “2” : {“name” : “b”}}}

this seems to get converted in the database record to
{test : [ {“name”, “a”}, {“name” : “b”}]}

This is not what I want.

if I include a structure like
{test : {“A1” : {“name”, “a”}, “A2” : {“name” : “b”}}}
it maintains the json structure in the database.

How can I stop this from happening?

I have the same structure in my mobile app using couchbase and java and it gets stored properly in the mobile couchbase database.

What versions of Couchbase Server and Node.js are you using? I’ve tried an upset with your structure (I changed the , after “name” to be a : )

bucket.upsert(“test2”, {test: {“1” : {“name”: “a”}, “2” : {“name” : “b”}}}, function(err, result) {

and the resulting document that I get looks like

{
  "test": {
    "1": {
      "name": "a"
    },
    "2": {
      "name": "b"
    }
  }
}

I also tried with the “1” and “2” out of quotes just in case there was some oddity there but it resulted in the same document structure.

Couchbase server - 5.0.1 community edition
node.js -v8,11,1

npm global packages are not always same version as local packages. (many of the packages are duplicated in both places.)
Trying to clean this up and have packages global.

couchbase (npm) is 2.4.6

I’m having trouble reproducing this, I’m using Couchbase 5.0.1 Community Edition and Node.js 8.11.1. I’m seeing the same as in my previous comment. There’s no chance that something somwhere in your code is doing something a bit odd and somehow converting the object to array?