Is JSON.parse supposed to be recursive?

I parse the json string like this:

ring = JSON.parse(response);

Now ringan object, but ring.stones is just a string when it should also be an object.

If I call:

ring.stones = JSON.parse(ring.stones);

Now this is the correct object.

I did not know if this behavior is correct, or maybe I have a problem that stops him from recursive analysis? If it is assumed that it recursively analyzes, are there any known problems that could prevent it?


Update

Here is the complete answer before parsing:

{ "ring_id": "9", "stone_count": "4", "style_number": "style 4", "syn10": "436.15", "gen10": "489.39", "syn14": "627,60", "gen14": "680,85", "": "", "": "", "engravings_count": "0", "engravings_char_count": "0", "engravings_band": "10", "": "[{\" stone_id\ ": \" 27 \ ",\" ring_id \ ":\" 9 \ ",\" stone_shape \ ":\" \ ",\" stone_x \ ":\" 132,80 \ ",\" stone_y \ ":\" 114,50 \ ",\" stone_width \ ":\" 71,60 \ ",\" stone_height \ ":\" 71,60 \ ",\" stone_rotation \ ": \" 0.00\ "\" stone_number \ ":\" 1 \ ",\" stone_mm_width \ ":\" 5.00 \ ",\" stone_mm_height \ ":\" 5.00 \ "}, {\" stone_id \ ": \" 28\ "\" ring_id \ ":\" 9 \ ",\" stone_shape \ ":\" \ ",\" stone_x \ ":\" 100,50 \ ",\" stone_y \ ": \" 166.20\ ",\" stone_width \ ":\" 36,20 \ ",\" stone_height \ ":\" 36,60 \ ",\" stone_rotation \ ":\" 0,00 \ ",\" stone_number \ ":\" 2 \ ",\" stone_mm_width \ ":\" 2,50 \ ",\" stone_mm_height \ ":\" 2.50 \ "}, {\" stone_id \ ":\" 29 \ ",\" ring_id \ ":\" 9 \ ",\" stone_shape \ ":\" \ ",\" stone_x \ ":\" 200,20 \ ",\" stone_y \ ":\" 105,10 \ ",\" stone_width \ ":\" 33.90 \ ", \" stone_height\ ": \" 33,90 \ ",\" stone_rotation \ ":\" 0,00 \ ",\" stone_number \ ":\" 3 \ ",\" stone_mm_width \ ":\" 2.50 \ ",\" stone_mm_height \ ":\" 2.50 \ "}, {\" stone_id \ ":\" 30 \ ",\" ring_id \ ":\" 9 \ ",\" stone_shape \ ":\" \ ",\" stone_x \ ":\" 165,80 \ ",\" stone_y \ ":\" 82.50 \ ",\" stone_width \ ":\" 35,50 \ ",\" stone_height \ ":\" 33,90 \ ",\" stone_rotation \ ":\" 0,00 \ ",\" stone_number \ ":\" 4 \ ",\" stone_mm_width \ ":\" 2.50\ ", \" stone_mm_height\ ": \" 2.50\ "}]", "images": "[{\" title\ ": \" white gold\ ", \" source\ ": \" Style4_4_W_M.png\ "}, {\" title\ ": \" yellow gold\ ", \" source\ ": \" Style4_4_Y_M.png\ "}]" }


2

mikerobi, , :

:

$row = $sth->fetch(PDO::FETCH_ASSOC);

$row['stones'] = getStones($ring_id);
$row['images'] = getRingVariations($ring_id);

return json_encode($row);

getStones getRingVariations json_encode 'd. , .

+5
2

JSON , , .

JSON :

{
    stones: "[{\"stone_id":\"27\"},{\"stone_id\":\"27\"}]"
}

:

{
    stones: [{"stone_id": 27},{"stone_id": 27}]
}

, , , , .

, , JSON, .

+5

, (response) . escape- (\") .

+2

All Articles