Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:34:51+00:00 2026-06-12T05:34:51+00:00

When a merchant adds a new product, as long as they type normal text

  • 0

When a merchant adds a new product, as long as they type normal text into the body_html field, it works great. However, when they try to add some HTML from either copy paste or adding image into the WYSIWYG editor (that has “”) we get the famous:

lexical error: invalid char in json text.

Now, they may be pasting from an unknown source, is there a way any has figured out how I could possible clean up the body_html before sending it on to ShopifyAPI?

By the way, I’m using PHP and the wcurl.php
https://github.com/sandeepshetty/wcurl

UPDATE:

lexical error: invalid char in json text.

              "{"product":{"title":"Sample Event
    (right here) ------^

CODE SAMPLE:

$shopify_data = array
(
   "product"=>array
   (
     "title"=>$rs->product_title,
     "body_html"=>$rs->product_details,
     "vendor"=>"My Companay",
     "product_type"=>"Laptop"
   )
);

foreach ($variant as $key => $value) {
  $shopify_data["product"]["variants"][$key] = array(
    "option1"=> $value->variant_name,
    "price"=> $value->price,
    "requires_shipping"=>'true',
    "inventory_management"=>"shopify",
    "inventory_quantity"=> $value->quantity
  );
}

// $shopify_data = json_encode($shopify_data);  // This does not work either.
$shopify_data = stripslashes(json_encode($shopify_data));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:34:53+00:00Added an answer on June 12, 2026 at 5:34 am

    If I understand this right the solution is:

    stripslashes(json_encode($params))
    

    I do this in my Shopify client:
    https://github.com/sandeepshetty/shopify_api/blob/1f538276e690bd7b95f9cbb4007576ecb2d3f6de/client.php#L52

    Note: PHP 5.4.0 has an option for this in json_encode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to rails and new to active merchant, just want to know
I've got a table with a field for Merchant's name and field with the
For example, I have several different merchant clients who I handle transactions for. They
I'm trying to use Active Merchant with a new Rails 3.1.3 app and I'm
For each product there are associated cost calculators like: discount, discount by merchant, bonus
I have an association, Shop habtm Products Product habtm Shops Shop belongs_to Merchant For
If I plug in the following into my console (Chrome): $('input[name=shopping-cart.merchant-private-data]'); it results in:
What does the if statement mean here? Merchant merchant1 =new Merchant(); if(!merchant1.SaveMerchantDdetails(x, y, z))
I was going through Ryan Bates' video on Active Merchant integration video Railscast #145
For my trading program, I have a Merchant class. A given Merchant object may

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.