Skip to content

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

Closed
@forksumit

Description

@forksumit

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

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions