EXCEPTION:位置10的JSON中意外的令牌n

问题描述:

我需要帮助解决我的错误。 我用angular2工作,我得到错误。EXCEPTION:位置10的JSON中意外的令牌n

import { Injectable } from '@angular/core'; 
import {Http} from '@angular/http'; 

import 'rxjs/add/operator/map'; 

@Injectable() 

export class PeopleService { 

    constructor(private _http: Http) { } 
    fetchPeople(){ 
    return this._http.get('/assets/people.json') 
       .map(res => res.json()); 
} 

enter image description here};

+0

您可以发布您JSON和你确认它是有效的? –

+0

你可以使用http://jsonlint.com/来测试你的JSON –

+0

而你的问题是... –

很简单 - 检查返回的JSON,第10个字符。那里有什么不对。这个错误意味着JSON不能被解析,因为结构无效。确保JSON格式良好:

Unexpected token n so - JSON在位置10中有一个n字符,它打破了它的格式。检查您是否用{}[]关闭了所有数据。

+0

谢谢,这是我的JSON格式 –

+0

感谢Koby Douek –

JSON文件无效。字符串应该使用双引号。

例如 [{ “名”: “Smael检查”, “状态”: “网络developper” }]