To resolve the issue with your JSON and HTML integration, follow these key steps:
1. **Escape HTML characters in JSON**:
```json
{
"name": "John Doe",
"address": "<div class='address'>123 Main St.<br/>Apt 4B</div>"
}
```
2. **Use `JSON.parse()` instead of `eval()`**:
```javascript
const raw = '{"name": "John Doe", "address": "
123 Main St.
Apt 4B
"}';
const parsed = JSON.parse(raw);
document.body.innerHTML = parsed.address;
```
3. **Server-side escaping (if applicable)**:
In languages like PHP:
```php
$address = htmlspecialchars("123 Main St.
Apt 4B
", ENT_QUOTES, 'UTF-8');
$json = json_encode(["address" => $address]);
```
4. **HTML injection example**:
```html
```
Avoid placing raw HTML directly in JSON values when it will be parsed by JavaScript. Always escape entities or use dedicated templating.