dotarj / PartialResponse

PartialResponse provides JSON partial response (partial resource) support for ASP.NET Web API.
Other
57 stars 26 forks source link

empty array is removed from json response #11

Closed xalikoutis closed 6 years ago

xalikoutis commented 6 years ago

Hi congrats for the great work,

so my problem is in my web api where all my request respond the following structure

{
totalCount:12,
data[....]
}

When the are no data

{
totalCount:0,
data[]
}

and apply fields=totalcount,data(field1,field2) then i get a response with data[] removed

{
totalCount:0
}

thats a problem because it cannot be mapped properly on the client

dotarj commented 6 years ago

Hi, can you please let me know which version of the package you're using: WebApi.PartialResponse or PartialResponse.AspNetCore.Mvc.Formatters.Json?

vhatsura commented 6 years ago

Hi, @dotarj! We faced with the same issue. We are using WebApi.PartialResponse 0.1.4 version

dotarj commented 6 years ago

Hi @vhatsura, thanks for the info. The current implementation removes an array if it becomes empty after filtering fields, but this also happens if the array was already empty. I'll try to figure out a solution to the problem.

dotarj commented 6 years ago

I've pushed a new version of WebApi.PartialResponse which does not remove an array if it was already empty: https://www.nuget.org/packages/WebApi.PartialResponse/1.0.0-beta3.