Terraform: jsonencode does not create JSON structure

Created on 6 Jun 2016  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version

0.6.16

Affected Resource(s)

jsonencode

Expected Behavior

What should have happened?

jsonencode("email:[email protected], dept:Development")

should have (?) turned into

{"email": "[email protected]","dept": "Development" }

Actual Behavior

What actually happened?

"\"email:[email protected], dept:Development\""

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

  • GH-5890
bug core question

Most helpful comment

Hi @rkulagowski! I agree the behaviour here is slightly weird. It's actually unclear to me what should happen when you JSON-encode a string without a key. I think we need to go back to the drawing board with this interpolation function and figure out what the semantics should be and get them documented. Thanks for bringing this to our attention!

cc @phinze.

All 3 comments

Hi @rkulagowski! I agree the behaviour here is slightly weird. It's actually unclear to me what should happen when you JSON-encode a string without a key. I think we need to go back to the drawing board with this interpolation function and figure out what the semantics should be and get them documented. Thanks for bringing this to our attention!

cc @phinze.

This is working as expected I believe. With first-class map/list support in 0.7 you can now give it a map and get the proper value and other interpolation functions exist to help convert strings to maps.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings