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
that’s my class:
export class Modelo{
id: number;
type: string;
size: number;
constructor() {
}
}
It turns out that the function return map()
, mounts the following object JavaScript
, that is, it inserts this property _$visited
: true:
{
"id": 28,
"type": "type",
"size": null,
"_$visited": true
}
That property "_$visited" is not part of my model there on the side of the Webservice, nor on the side of the front end, if I consume this Webservice by a Rest client (I use the Restlet Client), the returned json is the expected one or if I log the return of the res.json function itself():
{
"id": 28,
"type": "type",
"size": null
}
I’d like to know first where this property comes from "_$visited"
and what is the best way to get rid of it, because when I send this object to my web service again, it goes with this property.
In a quick Internet search, I saw that the place that uses this "_$visited" property is Primefaces, more specifically Primeng. You’re using this library?
– Marcus Hert da Coregio
Yes, I am using this library? can you pass me the reference?
– Henrique Santiago
I arrived at it through this site on Github https://github.com/primefaces/primeng/issues/1937 you probably don’t need to worry about this property, it’s just a Primeng control.
– Marcus Hert da Coregio
it happens that it is set and when I send a post with that same object pro web service, it gives error there on the other side.
– Henrique Santiago
I believe that any implementation you are using has some way of telling objects to ignore properties that are not mapped in your Backend. For example Jackson has @Jsonignoreproperties(ignoreUnknown = true), take a look.
– Marcus Hert da Coregio
I didn’t know this Annotation, vlw brother. it worked.
– Henrique Santiago
I have written an answer to help anyone else who has this problem. If you can accept it. Hug.
– Marcus Hert da Coregio