Question: I'm currently trying to parse a JSON from a data attribute but I'm getting an error: 

> 
> Uncaught SyntaxError: Unexpected token � in JSON at position 0
> 
> 
> 

This is my code: 

```js
jQuery( document ).ready( function ( $ ) {
 let variations = $( "span" ).data( "variations" );

 $( JSON.parse( variations ) ).each( function ( index, variation ) {
  console.log( variation );
 } );
} );
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<span data-variations='["\ud83d\udc36","\ud83d\udc31"]'></span>
```

I don't get it. I'm printing the JSON in PHP with this function but I'm stuck in my head here: 

```
<span data-variations='<?= esc_html( json_encode( $variations ) ) ?>'></span>

```

Answer: 
You are having this issue because `variations` already has the parsed value, [as said in the doc](https://api.jquery.com/data/) :

> 
> When a string starts with '{' or '[', then jQuery.parseJSON is used to parse it
> 
> 
> 

```js
jQuery( document ).ready( function ( $ ) {
 let variations = $( "span" ).data( "variations" );

 $( variations ).each( function ( index, variation ) {
  console.log( variation );
 } );
} );
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<span data-variations='["\ud83d\udc36","\ud83d\udc31"]'></span>
```
jQuery notices that the value of the `data-` attribute is valid JSON, so you get a parsed object from the `.data("variations")` call. There's no need to parse it yourself.