Hey there, I am getting a few errors when encoding a Javascript object:
- In an object that looks something like this:
...
"long_description":"The \"shufflebuilding\" game Smash Up starts with a simple premise: Take the twenty-card decks of two factions, shuffle <br> them into a forty-card deck, then compete to smash more Bases than your opponents! Each faction brings a different <br> game mechanism into play - pirates move cards, zombies bring cards back from the discard pile, dinosaurs have huge<br> power, and every combination of factions brings a different play experience.<br>",
...
All of the spaces are stripped from the description, resulting in:
...
The\"shufflebuilding\"gameSmashUpstartswithasimplepremise:Takethetwenty-carddecksoftwofactions,shuffle<br>themintoaforty-carddeck
...
Then, anything that has a colon at the end of it has quotes added:
...
The\"shufflebuilding\""gameSmashUpstartswithasimplepremise":Takethetwenty-carddecksoftwofactions,shuffle<br>themintoaforty-carddeck
...
This creates an invalid JSON object.
- In an object that looks like this:
...
"thumbnails":{"small":"https:\/\/www.x.com\/images\/default\/products\/x.png","medium":"https:\/\/www.x.com\/images\/default\/products\/x.png","large":"https:\/\/www.x.com\/images\/default\/products\/x.png"},
...
The https protocol has quotes added around it, similar to the previous issue. I was able to resolve this issue by changing your regex to the following:
$str = preg_replace('/([a-zA-Z0-9\_]+):(?!\\\\)/', '"$1":', $str);
But it's an incomplete solution at best.
Thanks for putting this package together!
Hey there, I am getting a few errors when encoding a Javascript object:
All of the spaces are stripped from the description, resulting in:
Then, anything that has a colon at the end of it has quotes added:
This creates an invalid JSON object.
The https protocol has quotes added around it, similar to the previous issue. I was able to resolve this issue by changing your regex to the following:
But it's an incomplete solution at best.
Thanks for putting this package together!