1. Home
  2. Docs
  3. Troubleshooting
  4. Unexpected end of JSON input

Unexpected end of JSON input

Alternative error message you might see: Uncaught SyntaxError: Expected property name or '}' in JSON at position 1

This JavasScript error may appear in your console if the value attribute of the hidden _wpcf7cf_options field is not escaped. (View source and search for _wpcf7cf_options.) It probably looks like this:

<input type="hidden" name="_wpcf7cf_options" value="{"form_id":9,"conditions":[{"then_field":"phone" ..." />

but it should look like this:

<input type="hidden" name="_wpcf7cf_options" value="{&quot;form_id&quot;:9,&quot;conditions&quot;:[{&quot;then_field&quot;:&quot;phone&quot; ..." />

Conditional fields uses a CF7 filter wpcf7_form_hidden_fields to add the hidden field. This filter in it’s turn will call the native wordpress function esc_attr to make sure the attribute is escaped properly. The esc_attr function (wp-includes/formatting.php line 3976) applies another filter called attribute_escape. So, you see, there are a couple of filters exposed where other plugins or your theme might be modifying the flow, causing the attribute not te be escaped.

The best way to figure out which plugin (or theme) is responsible for this, is to disable all your plugins (except CF7 and Conditional fields) and your theme, and hopefully the problem should be gone. Then start re-enabling plugins until you figure out which plugin causes the issue.

Was this article helpful to you? Yes No

How can we help?