• Resolved Pierre Helium

    (@pierrethenot)


    Hi,

    I’m having a weird issue when choosing JSON export file format. When I select “d/m/Y” date format it adds backslashes before each slash like so : “02\/10\/2019”.
    This issue doesn’t appear when using a different file format (XML, CSV…).

    Can you help me with this?

    Here are the export settings I’m using :

    {
    “now”: {
    “version”: “2.0”,
    “mode”: “now”,
    “title”: “”,
    “skip_empty_file”: true,
    “log_results”: false,
    “from_status”: [],
    “to_status”: [],
    “change_order_status_to”: “”,
    “statuses”: [
    “wc-pending”,
    “wc-processing”,
    “wc-on-hold”,
    “wc-completed”
    ],
    “from_date”: “”,
    “to_date”: “”,
    “shipping_locations”: [],
    “shipping_methods”: [],
    “item_names”: [],
    “item_metadata”: [],
    “user_roles”: [],
    “user_names”: [],
    “user_custom_fields”: [],
    “billing_locations”: [],
    “payment_methods”: [],
    “any_coupon_used”: “0”,
    “coupons”: [],
    “order_custom_fields”: [],
    “product_categories”: [],
    “product_vendors”: [],
    “products”: [],
    “exclude_products”: [],
    “product_taxonomies”: [],
    “product_custom_fields”: [],
    “product_attributes”: [],
    “product_itemmeta”: [],
    “format”: “JSON”,
    “format_xls_use_xls_format”: “0”,
    “format_xls_sheet_name”: “Commandes”,
    “format_xls_display_column_names”: “1”,
    “format_xls_auto_width”: “1”,
    “format_xls_direction_rtl”: “0”,
    “format_xls_force_general_format”: “0”,
    “format_xls_row_images_width”: “50”,
    “format_xls_row_images_height”: “50”,
    “format_csv_enclosure”: “\””,
    “format_csv_delimiter”: “,”,
    “format_csv_linebreak”: “\\r\\n”,
    “format_csv_display_column_names”: “1”,
    “format_csv_add_utf8_bom”: “0”,
    “format_csv_item_rows_start_from_new_line”: “0”,
    “format_csv_encoding”: “UTF-8”,
    “format_csv_delete_linebreaks”: “0”,
    “format_tsv_linebreak”: “\\r\\n”,
    “format_tsv_display_column_names”: “1”,
    “format_tsv_add_utf8_bom”: “0”,
    “format_tsv_encoding”: “UTF-8”,
    “format_xml_root_tag”: “Orders”,
    “format_xml_order_tag”: “Order”,
    “format_xml_product_tag”: “Product”,
    “format_xml_coupon_tag”: “Coupon”,
    “format_xml_prepend_raw_xml”: “”,
    “format_xml_append_raw_xml”: “”,
    “format_xml_self_closing_tags”: “1”,
    “format_pdf_display_column_names”: “1”,
    “format_pdf_repeat_header”: “1”,
    “format_pdf_orientation”: “L”,
    “format_pdf_page_size”: “A4”,
    “format_pdf_font_size”: “8”,
    “format_pdf_header_text”: “”,
    “format_pdf_footer_text”: “”,
    “format_pdf_pagination”: “C”,
    “format_pdf_fit_page_width”: “0”,
    “format_pdf_cols_width”: “25”,
    “format_pdf_cols_align”: “L”,
    “format_pdf_page_header_text_color”: “#000000”,
    “format_pdf_page_footer_text_color”: “#000000”,
    “format_pdf_table_header_text_color”: “#000000”,
    “format_pdf_table_header_background_color”: “#FFFFFF”,
    “format_pdf_table_row_text_color”: “#000000”,
    “format_pdf_table_row_background_color”: “#FFFFFF”,
    “format_pdf_logo_source_id”: “0”,
    “format_pdf_logo_source”: “”,
    “format_pdf_logo_width”: “0”,
    “format_pdf_logo_height”: “15”,
    “format_pdf_logo_align”: “R”,
    “format_pdf_row_images_width”: “15”,
    “format_pdf_row_images_height”: “15”,
    “format_html_display_column_names”: “1”,
    “format_html_repeat_header_last_line”: “0”,
    “format_html_font_size”: “13”,
    “format_html_header_text”: “”,
    “format_html_footer_text”: “”,
    “format_html_cols_align”: “L”,
    “format_html_header_text_color”: “#000000”,
    “format_html_footer_text_color”: “#000000”,
    “format_html_table_header_text_color”: “#000000”,
    “format_html_table_header_background_color”: “#FFFFFF”,
    “format_html_table_row_text_color”: “#000000”,
    “format_html_table_row_background_color”: “#FFFFFF”,
    “format_html_custom_css”: “”,
    “all_products_from_order”: “1”,
    “skip_refunded_items”: “1”,
    “skip_suborders”: “0”,
    “export_refunds”: “0”,
    “date_format”: “d\/m\/Y”,
    “time_format”: “”,
    “sort_direction”: “DESC”,
    “sort”: “order_id”,
    “format_number_fields”: “1”,
    “export_all_comments”: “0”,
    “export_refund_notes”: “0”,
    “strip_tags_product_fields”: “1”,
    “cleanup_phone”: “1”,
    “enable_debug”: “0”,
    “format_json_start_tag”: “[“,
    “format_json_end_tag”: “]”,
    “custom_php”: “0”,
    “custom_php_code”: “”,
    “mark_exported_orders”: “0”,
    “export_unmarked_orders”: “0”,
    “summary_report_by_products”: “0”,
    “duplicated_fields_settings”: [],
    “summary_report_by_customers”: “0”,
    “order_fields”: [
    {
    “segment”: “common”,
    “key”: “order_number”,
    “label”: “Num\u00e9ro de commande”,
    “format”: “string”,
    “colname”: “order_number”
    },
    {
    “segment”: “user”,
    “key”: “customer_user”,
    “label”: “ID du client”,
    “format”: “number”,
    “colname”: “customer_user”
    },
    {
    “segment”: “common”,
    “key”: “order_date”,
    “label”: “Date de commande”,
    “format”: “date”,
    “colname”: “datfact”
    },
    {
    “segment”: “user”,
    “key”: “static_field_2”,
    “label”: “datlivr”,
    “format”: “”,
    “colname”: “static_field_2”,
    “value”: “”
    },
    {
    “segment”: “user”,
    “key”: “static_field_3”,
    “label”: “repres”,
    “format”: “”,
    “colname”: “static_field_3”,
    “value”: “”
    },
    {
    “segment”: “user”,
    “key”: “static_field_4”,
    “label”: “etat”,
    “format”: “”,
    “colname”: “static_field_4”,
    “value”: “1”
    },
    {
    “segment”: “user”,
    “key”: “static_field_5”,
    “label”: “stori”,
    “format”: “”,
    “colname”: “static_field_5”,
    “value”: “1”
    },
    {
    “segment”: “common”,
    “key”: “customer_note”,
    “label”: “Note du client”,
    “format”: “string”,
    “colname”: “customer_note”
    },
    {
    “segment”: “products”,
    “key”: “products”,
    “label”: “Produits”,
    “format”: “undefined”,
    “colname”: “products”
    },
    {
    “segment”: “coupons”,
    “key”: “coupons”,
    “label”: “Coupons”,
    “format”: “undefined”,
    “colname”: “coupons”
    }
    ],
    “order_product_fields”: [
    {
    “label”: “UGS”,
    “key”: “sku”,
    “segment”: “products”,
    “format”: “string”,
    “colname”: “sku”
    },
    {
    “label”: “Quantit\u00e9”,
    “key”: “qty”,
    “segment”: “products”,
    “format”: “number”,
    “colname”: “qty”
    },
    {
    “label”: “Prix du produit”,
    “key”: “item_price”,
    “segment”: “products”,
    “format”: “money”,
    “colname”: “item_price”
    },
    {
    “label”: “pourc”,
    “key”: “static_field_7”,
    “segment”: “products”,
    “format”: “”,
    “colname”: “static_field_7”,
    “value”: “0”
    }
    ],
    “order_coupon_fields”: [],
    “id”: 0,
    “post_type”: “shop_order”,
    “export_rule_field”: “date”,
    “export_filename”: “orders-%y-%m-%d-%h-%i-%s.json”
    },
    “profiles”: [],
    “cron”: [],
    “order-action”: []
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    hi

    In JSON “/” and “\/” are equivalent.
    More details at https://stackoverflow.com/a/10314758

    BUT if you still need to remove backslashes, open section “Misc Settings” and add following PHP code.
    thanks, Alex

    add_filter( "woe_json_output_filter", function($json, $record, $formatter){
    	if ( $formatter->mode == 'preview' ) 
    		$flags = JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ;
    	else
    		$flags = JSON_UNESCAPED_SLASHES;
    	return json_encode($record,$flags);
    },10,3);
    Thread Starter Pierre Helium

    (@pierrethenot)

    Hi Alex,

    That works, thanks a lot.

    • This reply was modified 5 years, 5 months ago by Pierre Helium.
    Plugin Author algol.plus

    (@algolplus)

    you’re welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘weird \ backslash in json date format’ is closed to new replies.