{"id":23330,"date":"2020-09-28T20:56:00","date_gmt":"2020-09-29T03:56:00","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=23330"},"modified":"2020-09-28T20:59:29","modified_gmt":"2020-09-29T03:59:29","slug":"unexpected-token-in-json","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/","title":{"rendered":"SyntaxError: Unexpected Tokens in JSON"},"content":{"rendered":"\n<p>When working with JSON (JavaScript Object Notation), sometimes you might encounter an error that mentions <code>Unexpected token &lt; in JSON at position 0<\/code> or <code>Unexpected token o in JSON at position 1<\/code>.&nbsp; These are just examples \u2013 you might encounter a different token or a different position number. In this article, we\u2019ll take a look at the different ways we can debug this particular error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why the Error Occurs<\/h2>\n\n\n\n<p>Generally, the error occurs because there is an invalid JSON syntax or an error is thrown from the server. Double check the JSON syntax to be certain that it is a valid JSON object. Example of valid JSON syntax:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{ \n&quot;example1&quot;:\n [{\n  &quot;id&quot;: 1,\n  &quot;first_name&quot;: &quot;Ryun&quot;,\n  &quot;last_name&quot;: &quot;Lathwood&quot;,\n  &quot;email&quot;: &quot;rlathwood0@bandcamp.com&quot;,\n  &quot;gender&quot;: &quot;Male&quot;,\n  &quot;ip_address&quot;: &quot;211.73.218.126&quot;\n }, {\n  &quot;id&quot;: 2,\n  &quot;first_name&quot;: &quot;Goldarina&quot;,\n  &quot;last_name&quot;: &quot;Peatman&quot;,\n  &quot;email&quot;: &quot;gpeatman1@webs.com&quot;,\n  &quot;gender&quot;: &quot;Female&quot;,\n  &quot;ip_address&quot;: &quot;204.83.86.191&quot;\n }],\n &quot;example2&quot;: [{\n  &quot;id&quot;: 3,\n  &quot;first_name&quot;: &quot;Ken&quot;,\n  &quot;last_name&quot;: &quot;Birch&quot;,\n  &quot;email&quot;: &quot;kbirch1@arts.com&quot;,\n  &quot;gender&quot;: &quot;Male&quot;,\n  &quot;ip_address&quot;: &quot;211.56.78.190&quot;\n\n },\n {\n  &quot;id&quot;: 4,\n  &quot;first_name&quot;: &quot;Jane&quot;,\n  &quot;last_name&quot;: &quot;Carter&quot;,\n  &quot;email&quot;: &quot;jcarter1@carter.com&quot;,\n  &quot;gender&quot;: &quot;Female&quot;,\n  &quot;ip_address&quot;: &quot;203.33.86.191&quot;\n }]\n}\n<\/pre><\/div>\n\n\n\n<p>Characteristics of proper JSON syntax include:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Double quotes surrounding property names and string value names (single quotes not allowed).<\/li><li>If there are internal double quotes, be sure they are escaped<ol><li>Example:\u00a0<\/li><\/ol><\/li><\/ul>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>{\n  &quot;data&quot;: [{\n  \t&quot;code: &quot;1&quot;,\n \t&quot;message&quot;: &quot;This message has &quot;unescaped&quot; quotes. It will throw an error. This is the proper way to \\&quot;escape\\&quot; them.&quot;\n  }]\n}\n<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li>    Commas after each individual key:value pair (except the last key:value pair).<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>  Commas after each array (except for the last one).<\/li><\/ul>\n\n\n\n<p>Another possible reason for the error might be that the JSON being parsed isn\u2019t actually JSON. Double check the response coming from the server to be sure that it\u2019s returning a JSON response and not some sort of HTML or XML response (this is why we might get an <code>uncaught syntaxerror: unexpected token &lt; in JSON at position 0<\/code> error).&nbsp;<br><\/p>\n\n\n\n<p>As you navigate this error, be sure to use the developer tools to your advantage. The console and the network tab will both be your friend as you debug these types of errors.&nbsp;<br><\/p>\n\n\n\n<p>The more you work with JSON, the faster you will get at being able to interpret these types of errors!<br><\/p>\n","protected":false},"excerpt":{"rendered":"When working with JSON (JavaScript Object Notation), sometimes you might encounter an error that mentions Unexpected token &lt; in JSON at position 0 or Unexpected token o in JSON at position 1.&nbsp; These are just examples \u2013 you might encounter a different token or a different position number. In this article, we\u2019ll take a look&hellip;","protected":false},"author":77,"featured_media":23331,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-23330","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":[]},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Unexpected Tokens in JSON | Career Karma<\/title>\n<meta name=\"description\" content=\"Unexpected Tokens in your JSON can be a common error. In this article, we&#039;ll take a look at how to get rid of those errors for good!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SyntaxError: Unexpected Tokens in JSON\" \/>\n<meta property=\"og:description\" content=\"Unexpected Tokens in your JSON can be a common error. In this article, we&#039;ll take a look at how to get rid of those errors for good!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-29T03:56:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-29T03:59:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/abcd.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1066\" \/>\n\t<meta property=\"og:image:height\" content=\"1600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Christina Kopecky\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christina Kopecky\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/\"},\"author\":{\"name\":\"Christina Kopecky\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"headline\":\"SyntaxError: Unexpected Tokens in JSON\",\"datePublished\":\"2020-09-29T03:56:00+00:00\",\"dateModified\":\"2020-09-29T03:59:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/\"},\"wordCount\":258,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/abcd.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/\",\"name\":\"Unexpected Tokens in JSON | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/abcd.jpg\",\"datePublished\":\"2020-09-29T03:56:00+00:00\",\"dateModified\":\"2020-09-29T03:59:29+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\"},\"description\":\"Unexpected Tokens in your JSON can be a common error. In this article, we'll take a look at how to get rid of those errors for good!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/abcd.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/09\\\/abcd.jpg\",\"width\":1066,\"height\":1600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/unexpected-token-in-json\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/javascript\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SyntaxError: Unexpected Tokens in JSON\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/ae0cdc4a5d198690d78482646894074e\",\"name\":\"Christina Kopecky\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/image-3-150x150.jpg\",\"caption\":\"Christina Kopecky\"},\"description\":\"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.\",\"sameAs\":[\"http:\\\/\\\/www.linkedin.com\\\/in\\\/cmvnk\"],\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/christina-kopecky\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Unexpected Tokens in JSON | Career Karma","description":"Unexpected Tokens in your JSON can be a common error. In this article, we'll take a look at how to get rid of those errors for good!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/","og_locale":"en_US","og_type":"article","og_title":"SyntaxError: Unexpected Tokens in JSON","og_description":"Unexpected Tokens in your JSON can be a common error. In this article, we'll take a look at how to get rid of those errors for good!","og_url":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-09-29T03:56:00+00:00","article_modified_time":"2020-09-29T03:59:29+00:00","og_image":[{"width":1066,"height":1600,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/abcd.jpg","type":"image\/jpeg"}],"author":"Christina Kopecky","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Christina Kopecky","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/"},"author":{"name":"Christina Kopecky","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"headline":"SyntaxError: Unexpected Tokens in JSON","datePublished":"2020-09-29T03:56:00+00:00","dateModified":"2020-09-29T03:59:29+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/"},"wordCount":258,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/abcd.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/","url":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/","name":"Unexpected Tokens in JSON | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/abcd.jpg","datePublished":"2020-09-29T03:56:00+00:00","dateModified":"2020-09-29T03:59:29+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"description":"Unexpected Tokens in your JSON can be a common error. In this article, we'll take a look at how to get rid of those errors for good!","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/abcd.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/09\/abcd.jpg","width":1066,"height":1600},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/unexpected-token-in-json\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"SyntaxError: Unexpected Tokens in JSON"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e","name":"Christina Kopecky","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","caption":"Christina Kopecky"},"description":"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.","sameAs":["http:\/\/www.linkedin.com\/in\/cmvnk"],"url":"https:\/\/careerkarma.com\/blog\/author\/christina-kopecky\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=23330"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/23330\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/23331"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=23330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=23330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=23330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}