Convert JSON in schema.TypeString

Hello,

I have a parameter in my custom provider which is defined as below:

"local_context_data": {
    Type:     schema.TypeString,
    Optional: true,
},

This parameter is used to store JSON so in terraform code I use:

local_context_data = jsonencode({"hello"="world"})

But when I execute terraform I have the error message from the API:

Error: [POST /virtualization/virtual-machines/][400] virtualization_virtual-machines_create default map[local_context_data:[JSON data must be in object form. Example: {“foo”: 123}]]
on vm.tf line 73, in resource “netbox_virtualization_vm” “vm”:
73: resource “netbox_virtualization_vm” “vm” {

I can see with tcpdump that {"hello"="world"} is sent to the API and not {“hello”=“world”}.
Do we have a function in the SDK to address this issue ? Or I need to do something in GO ?

Thanks.

Hmm, I’m not sure I have enough detail to help with this. The plugin should be getting a correctly formatted string; the jsonencode function you’re calling does that translation in Terraform before it ever reaches your provider, so if you’re seeing {"hello" = "world"} in request logs, something’s going wrong outside the SDK, because the SDK can’t influence that. You’re either passing the wrong thing to the request or something funky is happening.

Do you have the code in question online somewhere?

Sorry I made a mistake in first post.
I can see with tcpdump that {\“hello\”=\“world\”} is sent to the API and not {“hello”=“world”}.

Could you confirm that a TypeJSON does not exist which I can use in my provider ?
I would like to test with pure JSON and not JSON inside string.