Json parsing error
-
I have a small problem with using double quotes in my text.
When they are used the map is not displayed and I get the following error:
SyntaxError: JSON.parse: expected ‘,’ or ‘}’ after property value in object at line 1 column 3178 of the JSON data travelersmap.js:208:25
After a little debugging I found that this is due to the double quotes that are in the excerpt, and thus mess up the JSON somehow.I looked at several solutions: Choosing the option not to show the excerpt text, but this does not help. Changing the double quotes in the blog text to single quotes, so they are not in the excerpt any more. This works, but as multiple people write posts this is not a convenient way.
I have looked if it is possible to sanitize the excerpt before it is used, but I did not find a way there. As a temporary solution, I have made a small change to the code:
travelers-map/includes/public/cttm-shortcode.php
Around line 238:// $cttm_postdatas['excerpt'] = get_the_excerpt($cttm_post->ID); $cttm_postdatas['excerpt'] = "";
This helps, and the map displays fine now. But I do not want to make changes to the plugin. Is there another way that I missed, or is this something you can solve in the plugin?
Many thanks,
Alex
- The topic ‘Json parsing error’ is closed to new replies.