json 응답에 문제가 있습니다. 해당 오류로 인해 json이 적절한 형식으로 표시되지 않습니다. 아래 오류가 표시됩니다json 응답에 오류가 있습니다.
Error: Parse error on line 2: { "Shirts" [{ "SubCategory": -----------^ Expecting 'EOF', '}', ':', ',', ']', got '['"
내 json 응답은 다음과 같습니다.
{
"Shirts" [{
"SubCategory": "Coalesce: Functioning On Impatience T-Shirt"
} {
"SubCategory": "Ink Eater: Krylon Bombear Destroyed Tee"
} {
"SubCategory": "The Only Children: Paisley T-Shirt"
} {
"SubCategory": "Zolof The Rock And Roll Destroyer: LOL Cat T-shirt"
} {
"SubCategory": "Coalesce: Functioning On Impatience T-Shirt"
} {
"SubCategory": "Coalesce: Functioning On Impatience T-Shirt"
} {
"SubCategory": "Ink Eater: Krylon Bombear Destroyed Tee"
} {
"SubCategory": "Ink Eater: Krylon Bombear Destroyed Tee"
} {
"SubCategory": "The Only Children: Paisley T-Shirt"
} {
"SubCategory": "The Only Children: Paisley T-Shirt"
} {
"SubCategory": "Zolof The Rock And Roll Destroyer: LOL Cat T-shirt"
} {
"SubCategory": "Zolof The Rock And Roll Destroyer: LOL Cat T-shirt"
} {
"SubCategory": "Zolof The Rock And Roll Destroyer: LOL Cat T-shirt"
} {
"SubCategory": "Zolof The Rock And Roll Destroyer: LOL Cat T-shirt"
} {
"SubCategory": "Zolof The Rock And Roll Destroyer: LOL Cat T-shirt"
} {
"SubCategory": "Coalesce: Functioning On Impatience T-Shirt"
} {
"SubCategory": "Ink Eater: Krylon Bombear Destroyed Tee"
} {
"SubCategory": "The Only Children: Paisley T-Shirt"
} {
"SubCategory": "Zolof The Rock And Roll Destroyer: LOL Cat T-shirt"
}], {
"Shoes" [{
"SubCategory": "ASICS\u00ae Men's GEL-Kayano\u00ae XII"
} {
"SubCategory": "Kenneth Cole New York Men's Con-verge Slip-on"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "ASICS\u00ae Men's GEL-Kayano\u00ae XII"
} {
"SubCategory": "ASICS\u00ae Men's GEL-Kayano\u00ae XII"
} {
"SubCategory": "ASICS\u00ae Men's GEL-Kayano\u00ae XII"
} {
"SubCategory": "ASICS\u00ae Men's GEL-Kayano\u00ae XII"
} {
"SubCategory": "Kenneth Cole New York Men's Con-verge Slip-on"
} {
"SubCategory": "Kenneth Cole New York Men's Con-verge Slip-on"
} {
"SubCategory": "Kenneth Cole New York Men's Con-verge Slip-on"
} {
"SubCategory": "Kenneth Cole New York Men's Con-verge Slip-on"
} {
"SubCategory": "Steven by Steve Madden Pryme Pump"
} {
"SubCategory": "Nine West Women's Lucero Pump"
} {
"SubCategory": "ECCO Womens Golf Flexor Golf Shoe"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Steven by Steve Madden Pryme Pump"
} {
"SubCategory": "Steven by Steve Madden Pryme Pump"
} {
"SubCategory": "Steven by Steve Madden Pryme Pump"
} {
"SubCategory": "Steven by Steve Madden Pryme Pump"
} {
"SubCategory": "Nine West Women's Lucero Pump"
} {
"SubCategory": "Nine West Women's Lucero Pump"
} {
"SubCategory": "Nine West Women's Lucero Pump"
} {
"SubCategory": "ECCO Womens Golf Flexor Golf Shoe"
} {
"SubCategory": "ECCO Womens Golf Flexor Golf Shoe"
} {
"SubCategory": "ECCO Womens Golf Flexor Golf Shoe"
} {
"SubCategory": "CN Clogs Beach\/Garden Clog"
} {
"SubCategory": "ASICS\u00ae Men's GEL-Kayano\u00ae XII"
} {
"SubCategory": "Kenneth Cole New York Men's Con-verge Slip-on"
} {
"SubCategory": "Anashria Womens Premier Leather Sandal"
} {
"SubCategory": "Steven by Steve Madden Pryme Pump"
} {
"SubCategory": "Nine West Women's Lucero Pump"
} {
"SubCategory": "ECCO Womens Golf Flexor Golf Shoe"
}],
{
"Cell Phones" [{
"SubCategory": "Nokia 2610 Phone"
} {
"SubCategory": "BlackBerry 8100 Pearl"
} {
"SubCategory": "Sony Ericsson W810i"
} {
"SubCategory": "AT&T 8525 PDA"
} {
"SubCategory": "Samsung MM-A900M Ace"
} {
"SubCategory": "HTC Touch Diamond"
}],
{
"Cameras" [{
"SubCategory": "Canon Digital Rebel XT 8MP Digital SLR Camera"
} {
"SubCategory": " Argus QC-2185 Quick Click 5MP Digital Camera"
} {
"SubCategory": "Canon PowerShot A630 8MP Digital Camera with 4x Optical Zoom"
} {
"SubCategory": "Kodak EasyShare C530 5MP Digital Camera"
} {
"SubCategory": "SLR Camera Tripod"
} {
"SubCategory": "Universal Camera Case"
} {
"SubCategory": "Universal Camera Charger"
} {
"SubCategory": " Olympus Stylus 750 7.1MP Digital Camera"
}],
{
"Computers" [{
"SubCategory": "Apevia Black X-Cruiser Case ATX Mid-Tower Case (Default)"
} {
"SubCategory": "NZXT Lexa Silver Aluminum ATX Mid-Tower Case (Default)"
} {
"SubCategory": "AMD Phenom X4 9850 Black Ed. 2.50GHz Retail"
} {
"SubCategory": "22\" Syncmaster LCD Monitor"
} {
"SubCategory": "AMD A64 X2 3800+ 2.0GHz OEM"
} {
"SubCategory": "Western Digital - 1TB HD - 7200RPM"
} {
"SubCategory": "Western Digital 500GB HD - 7200RPM"
} {
"SubCategory": "Intel C2D E8400 3.0GHz Retail"
} {
"SubCategory": "24\" Widescreen Flat-Panel LCD Monitor"
} {
"SubCategory": "Intel Core 2 Extreme QX9775 3.20GHz Retail"
} {
"SubCategory": "Seagate 500GB HD - 5400RPM"
} {
"SubCategory": "Seagate 250GB HD - 5400RPM"
} {
"SubCategory": "19\" Widescreen Flat-Panel LCD Monitor"
} {
"SubCategory": "30\" Flat-Panel TFT-LCD Cinema HD Monitor"
} {
"SubCategory": "Sony VAIO 11.1\" Notebook PC"
} {
"SubCategory": "Microsoft Natural Ergonomic Keyboard 4000"
} {
"SubCategory": "Logitech Cordless Optical Trackman"
} {
"SubCategory": "Logitech diNovo Edge Keyboard"
} {
"SubCategory": "Microsoft Wireless Optical Mouse 5000"
} {
"SubCategory": "Gaming Computer"
} {
"SubCategory": "My Computer"
} {
"SubCategory": "Apple MacBook Pro MA464LL\/A 15.4\" Notebook PC"
} {
"SubCategory": "Acer Ferrari 3200 Notebook Computer PC"
} {
"SubCategory": "Crucial 2GB PC4200 DDR2 533MHz Memory"
} {
"SubCategory": "Crucial 1GB PC4200 DDR2 533MHz Memory"
} {
"SubCategory": "Crucial 512MB PC4200 DDR2 533MHz Memory"
} {
"SubCategory": "Computer"
} {
"SubCategory": "Toshiba M285-E 14\""
}],
{
"Hoodies" [{
"SubCategory": "The Get Up Kids: Band Camp Pullover Hoodie"
}],
{
"Living Room" [{
"SubCategory": "Ottoman"
} {
"SubCategory": "Chair"
} {
"SubCategory": "Couch"
} {
"SubCategory": "Magento Red Furniture Set"
}],
{
"Bedroom" [{
"SubCategory": "Akio Dresser"
} {
"SubCategory": "Barcelona Bamboo Platform Bed"
}],
}
내 코드입니다.
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
if ($ids)
{
foreach ($ids as $id)
{
$cat = Mage::getModel('catalog/category');
$cat->load($id);
if($cat->getLevel()==3 && $cat->getIsActive()==1)
{
$category1 = Mage::getModel('catalog/category')->load($cat->getId());
$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('name')
->addCategoryFilter($category1);
// echo "<b>".$cat->getName()."</b><br>";
$response["data"] = array();
$response["data"]["mainCategory"] = $cat->getName();
//echo json_encode($response);
echo "{";
echo json_encode($cat->getName());
echo "[";
foreach ($products as $product) { //print_r($product->getData());exit;
// echo " " . $product->getName() . "<br/>";
// echo json_encode($response);
$response["SubCategory"] = array();
$result["SubCategory"] = $product->getName();
echo json_encode($result);
}
echo ']'.',';
}
}
}
echo '}';
* 쉼표 *에 대해 들어 보셨습니까? 당신은 그 중 일부를 넣어야합니다. –