Endiss
Endiss

Reputation: 699

Nhibernate with Json.net 4.0

Hi can anyone help me with json serializer and nhibernate, i want to tell json how deep he should go with serialization something like :

Employess=>Company=>Job

and i wanna serialize only

Employess=>Company and here the break for json.

Upvotes: 0

Views: 153

Answers (2)

Mr Mush
Mr Mush

Reputation: 1538

You should decorate the Job property with [JsonIgnore] attribute.

[JsonIgonre]
public <JobType> Job {get; set;}

This way the serializer will ignore this property. You will need to add the proper using statement to your class header.

Upvotes: 1

Zipper
Zipper

Reputation: 7204

Generally you want to create a DTO object whose responsibility is knowing how to serialize itself out. It shouldn't really be the responsibility of the nhibernate object to know how to translate itself in to something that the json consumer needs.

Upvotes: 3

Related Questions