I have build a website with geolocalisation : the customer can add resources with severals fields and geolocation coordonates.
A json file is generated and it’s working well.
But sometimes, my customer fill a TV field with forbidden characters such as " of invisible spaces… which are invalidate the json file.
It’s need my manual intervention to determine where the issue is and I wonder if there is a easy and flexible way to avoid this usecase.
Think you’d be better off using the API to grab the value from the TV, assuming there’s only one or two, stick them in an associative array and then json_encode that. If you didn’t want to do all that work converting your template to that approach, you could just make a snippet that would do it for the problematic fields and then call them as tags in your template.
You could go down the plugin route and do a search and replace on the TV data during a save but there are a lot of characters that could potentially cause problems in your JSON so unless you can guarantee coverage for all of them and proper entity conversion etc, this doesn’t seem like a very robust solution.