How to solve semantically differences in the new framework

Hello,

I am developing a new provider using the latest framework development. This provider creates a resource with content in JSON schema format. I have completed implementing all the methods, and they are functioning as expected. However, the read method is detecting differences between the file used to create the resource and the resource’s state content.

The differences identified by the Terraform plan are semantic in nature. I resolved this issue using a specific SDK function. Nevertheless, I am unsure about how to achieve the same result in the new framework. According to my research, I need to utilize Plan Modifiers and Custom Types, but I require guidance on how to implement them effectively.

			"schema": {
				Type:     schema.TypeString,
				Required: true,
				DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
					newJSON, _ := structure.NormalizeJsonString(new)
					oldJSON, _ := structure.NormalizeJsonString(old)
					return newJSON == oldJSON

Unless I’ve misunderstood, I don’t think you need a PlanModifier in this case, just a custom type whose Equal() method does the right thing when comparing JSON strings.

@austin.valle wrote one of those already. It’s available here.

To use it, you’d use jsontypes.Normalized in the “model” struct, and put the following in the attribute schema:

CustomType: jsontypes.NormalizedType{},