Title: Wrong JSON format
Last modified: August 30, 2016

---

# Wrong JSON format

 *  Resolved [ChocoTUx](https://wordpress.org/support/users/chocotux/)
 * (@chocotux)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wrong-json-format/)
 * Hi, thanks for plugin, but I have some wrong with it.
 * When I try sync any translation file (po or pot) it end with json error (unexpected
   end of file).
 * last line – {“id”:””,”source”:”Testimonials Extra information”,”target”:””,”refs”:”
   plugins\/ravis-booking\/fields\/testimonials.php:97″,”notes”:”$id”}],”headers”:
 * This is what I find out about this.
 * It add part ‘headers’ to the Json (and because it is empty array() ) it makes
   some error.
 * In file loco-posyncs.php at line 59 is condition
 *     ```
       $headers = array();
           if( '' === $exp[0]['source'] ){
               $keep = array('Project-Id-Version','Language-Team','POT-Creation-Date','POT-Revision-Date');
               $head = loco_parse_po_headers( $exp[0]['target'] );
               $headers = array_intersect_key( $head->export(), array_flip($keep) );
               /*/ add prefixed header keys that can't be included above
               foreach( $head as $key => $value ){
                   if( 0 === strpos($key, 'X-Poedit-' ) ){
                       $headers[$key] = $value;
                   }
               }*/
               $exp[0] = array();
           }
       ```
   
 * but variable $exp[0][‘source’] is not empty (start some constant).
 * It works few days ago, but Im not edit nothing from the loco.
 * Thank you.
 * [https://wordpress.org/plugins/loco-translate/](https://wordpress.org/plugins/loco-translate/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wrong-json-format/#post-6738703)
 * The broken JSON you’ve posted wouldn’t be because of an empty array. The empty
   array should just output `"headers":[]`
 * The JSON is probably being truncated for some other reason. Possibly some other
   part of WordPress is generating junk output before the JSON, making the content
   length header wrong.
 * See also: [https://localise.biz/help/wordpress/translate-plugin/faqs#parseerror](https://localise.biz/help/wordpress/translate-plugin/faqs#parseerror)
 *  Thread Starter [ChocoTUx](https://wordpress.org/support/users/chocotux/)
 * (@chocotux)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wrong-json-format/#post-6738813)
 * Ye its my fault. I have some problem between windows and utf-8 coding and when
   you load long of json – header(‘Content-Length: ‘.strlen($body), true ); its 
   make some mistake.
 * But thank you for help.
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wrong-json-format/#post-6738849)
 * Encoding shouldn’t make any difference because strlen gives **bytes** not characters,
   which is correct for Content-Length. Also the JSON encoding should convert multi-
   byte characters to “\uxxxx” strings anyway.
 * Please post all the body received by your browser and its supposed content length.
 *  Thread Starter [ChocoTUx](https://wordpress.org/support/users/chocotux/)
 * (@chocotux)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wrong-json-format/#post-6738855)
 * Finaly I had convert all files (included in this ajax proccess) to UTF without
   BOM and shutdown header (content length) and its works.
 * I know that is not the best idea, but I had spend lot of time about this problem
   a I guest the problem will be in other file with wrong format, so you plugin 
   is fenomenal (really I love ajax things) and I fix my IDE so this problem will
   not happen again.
 * Thank you for you support.
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/wrong-json-format/#post-6738857)
 * Interesting result. Thanks for posting.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Wrong JSON format’ is closed to new replies.

 * ![](https://ps.w.org/loco-translate/assets/icon-256x256.png?rev=1000676)
 * [Loco Translate](https://wordpress.org/plugins/loco-translate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/loco-translate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/loco-translate/)
 * [Active Topics](https://wordpress.org/support/plugin/loco-translate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/loco-translate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/loco-translate/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/wrong-json-format/#post-6738857)
 * Status: resolved