Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct.to_json does not allow dicts. #5542

Closed
ttsugriy opened this issue Jul 8, 2018 · 0 comments
Closed

struct.to_json does not allow dicts. #5542

ttsugriy opened this issue Jul 8, 2018 · 0 comments
Assignees

Comments

@ttsugriy
Copy link
Contributor

ttsugriy commented Jul 8, 2018

Description of the problem / feature request:

When passing a dict as a value of one of the struct fields an error

Invalid text format, expected a struct, a string, a bool, or an int but got a dict for struct field 'config'

is encountered.

Feature requests: what underlying problem are you trying to solve with this feature?

Dicts are very similar to structs and should be supported.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Invoke

struct(config={'key': 'value'}).to_json()

and observe:

struct(config={'key': 'value'}).to_json()
ttsugriy added a commit to ttsugriy/bazel that referenced this issue Jul 8, 2018
… struct.to_json.

Dictionaries are frequently used for generic configuration descriptions especially
given that `struct` is not allowed in build files.

In order to be JSON-compatible, only dictionaries with string keys are allowed.
Technically Python also allows integers and booleans by automatically converting
them to strings, but this is confusing and not necessarily a good thing to do.

Fixes bazelbuild#5542
ttsugriy added a commit to ttsugriy/bazel that referenced this issue Jul 8, 2018
… struct.to_json.

Dictionaries are frequently used for generic configuration descriptions especially
given that `struct` is not allowed in build files.

In order to be JSON-compatible, only dictionaries with string keys are allowed.
Technically Python also allows integers and booleans by automatically converting
them to strings, but this is confusing and not necessarily a good thing to do.

Fixes bazelbuild#5542
ttsugriy added a commit to ttsugriy/bazel that referenced this issue Jul 8, 2018
… struct.to_json.

Dictionaries are frequently used for generic configuration descriptions especially
given that `struct` is not allowed in build files.

In order to be JSON-compatible, only dictionaries with string keys are allowed.
Technically Python also allows integers and booleans by automatically converting
them to strings, but this is confusing and not necessarily a good thing to do.

Fixes bazelbuild#5542
ttsugriy added a commit to ttsugriy/bazel that referenced this issue Jul 8, 2018
… struct.to_json.

Dictionaries are frequently used for generic configuration descriptions especially
given that `struct` is not allowed in build files.

In order to be JSON-compatible, only dictionaries with string keys are allowed.
Technically Python also allows integers and booleans by automatically converting
them to strings, but this is confusing and not necessarily a good thing to do.

Fixes bazelbuild#5542
ttsugriy added a commit to ttsugriy/bazel that referenced this issue Jul 8, 2018
… struct.to_json.

Dictionaries are frequently used for generic configuration descriptions especially
given that `struct` is not allowed in build files.

In order to be JSON-compatible, only dictionaries with string keys are allowed.
Technically Python also allows integers and booleans by automatically converting
them to strings, but this is confusing and not necessarily a good thing to do.

Fixes bazelbuild#5542
@laurentlb laurentlb self-assigned this Jul 13, 2018
werkt pushed a commit to werkt/bazel that referenced this issue Aug 2, 2018
… struct.to_json.

Dictionaries are frequently used for generic configuration descriptions especially
given that `struct` is not allowed in build files.

In order to be JSON-compatible, only dictionaries with string keys are allowed.
Technically Python also allows integers and booleans by automatically converting
them to strings, but this is confusing and not necessarily a good thing to do.

Fixes bazelbuild#5542

Closes bazelbuild#5543.

PiperOrigin-RevId: 206049754
alandonovan pushed a commit to google/starlark-go that referenced this issue Mar 29, 2019
This is a sketch of a standard module for JSON encoding/decoding for Starlark.

It is intended to subsume, generalize, and eventually
replace the ill-conceived struct.to_json method.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542

Change-Id: I297ffaee9349eedeeb52f5a88f40636a4095f997
alandonovan pushed a commit to google/starlark-go that referenced this issue Mar 29, 2019
This is a sketch of a standard module for JSON encoding/decoding for Starlark.

It is intended to subsume, generalize, and eventually
replace the ill-conceived struct.to_json method.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542

Change-Id: I297ffaee9349eedeeb52f5a88f40636a4095f997
alandonovan pushed a commit to google/starlark-go that referenced this issue Apr 2, 2019
This is a sketch of a standard module for JSON encoding/decoding for Starlark.

It is intended to subsume, generalize, and eventually
replace the ill-conceived struct.to_json method.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542

Change-Id: I297ffaee9349eedeeb52f5a88f40636a4095f997
alandonovan pushed a commit to google/starlark-go that referenced this issue Mar 5, 2020
This change defines a standard Starlark module for JSON encoding and decoding.
See json.go for documentation.

It is intended to subsume, generalize, and eventually
replace Bazel's ill-conceived struct.to_json method.

The json module is predeclared in the Starlark REPL environment.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542
bazelbuild/bazel#10176

Change-Id: I297ffaee9349eedeeb52f5a88f40636a4095f997
alandonovan pushed a commit to google/starlark-go that referenced this issue Mar 5, 2020
This change defines a standard Starlark module for JSON encoding and decoding.
See json.go for documentation.

It is intended to subsume, generalize, and eventually
replace Bazel's ill-conceived struct.to_json method.

The json module is predeclared in the Starlark REPL environment.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542
bazelbuild/bazel#10176

Change-Id: I297ffaee9349eedeeb52f5a88f40636a4095f997
alandonovan pushed a commit to google/starlark-go that referenced this issue Mar 6, 2020
This change defines a standard Starlark module for JSON encoding and decoding.
See json.go for documentation.

It is intended to subsume, generalize, and eventually
replace Bazel's ill-conceived struct.to_json method.

The json module is predeclared in the Starlark REPL environment.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542
bazelbuild/bazel#10176

Change-Id: I297ffaee9349eedeeb52f5a88f40636a4095f997
alandonovan pushed a commit to google/starlark-go that referenced this issue Jun 11, 2020
This change defines a standard Starlark module for JSON encoding and decoding.
See json.go for documentation.

It is intended to subsume, generalize, and eventually
replace Bazel's ill-conceived struct.to_json method.

The json module is predeclared in the Starlark REPL environment.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542
bazelbuild/bazel#10176
bazelbuild/starlark#83
bazelbuild/bazel#3732

Change-Id: I297ffaee9349eedeeb52f5a88f40636a4095f997
alandonovan pushed a commit to google/starlark-go that referenced this issue Jun 11, 2020
This change defines a standard Starlark module for JSON encoding and decoding.
See json.go for documentation.

It is intended to subsume, generalize, and eventually
replace Bazel's ill-conceived struct.to_json method.

The json module is predeclared in the Starlark REPL environment.

See related issues:
bazelbuild/bazel#7896
https://buganizer.corp.google.com/issues/23962735
https://buganizer.corp.google.com/issues/70210417
bazelbuild/bazel#7879 (comment)
bazelbuild/bazel#5542
bazelbuild/bazel#10176
bazelbuild/starlark#83
bazelbuild/bazel#3732
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants