'_ $ visited' property on JavaScript object on return of mapv () function from Obervable

0

I have a WebService implemented with JAX-RS and I'm consuming it with a service ( utilizando Angular 2 )

Follow the service:

@Injectable()
export class ModeloService {

  constructor(private http: Http) {
  }

  getAll(): Observable<Modelo[]> {
    return this.http.get(myEnvironment.MODELO_SERVICE_PATH)
      .map(res => <Modelo[]> res.json());
  }

}

Modelo is this my class:

export class Modelo{
  id: number;
  type: string;
  size: number;

  constructor() {

  }

}

It happens that the return of the function map() , mounts the following object JavaScript , that is, it inserts this property _$visited : true:

{
  "id": 28,
  "type": "type",
  "size": null,
  "_$visited": true
}

This "

asked by anonymous 17.01.2018 / 18:22

1 answer

2

This property is added by PrimeNG to perform some library controls. Theoretically it should not influence the sending of requests to its backend.

But if the backend is throwing exceptions saying that it does not know the property, you can use an annotation from your JSON library to ignore these unknown properties.

An example of Jackson's annotation in the communication class:

@JsonIgnoreProperties(ignoreUnknown = true)

This way the library will not attempt to parse this property.

    
17.01.2018 / 19:51