googleapis/python-spanner

Improper initialisation of JsonObject when param itself is JsonObject whose top level is a list

forksumit opened this issue · 0 comments

When calling JsonObject on a JsonObject when top level of data is a list (ex: JsonObject(JsonObject([{"k": "v"}]))) returns a empty JsonObject ({})

Environment details

  • OS: MacOS / Linux
  • Python version: 3.11.4
  • pip version: 24.0
  • google-cloud-spanner version: 3.47.0

Steps to reproduce

from google.cloud.spanner_v1 import JsonObject

data = {"key": "value"}
x = JsonObject(data)
y = JsonObject(x)
print(x, y)

data = [{"key": "value"}]
x = JsonObject(data)
y = JsonObject(x)
print(x, y)

Expected Output:

{'key': 'value'} {'key': 'value'}
[{'key': 'value'}] [{'key': 'value'}]

Got Output:

{'key': 'value'} {'key': 'value'}
[{'key': 'value'}] {}

If fixed, should also fix: googleapis/python-spanner-sqlalchemy#404