When input an empty json slice, it is transferred as "nil", instead of "[]"

In detail, trpc-go is used.
When I make a request, I input an empty json slice like:
{

“dataArray”: [ ]
}
When I transform it to the struct like:
{

dataArray: []*data
}
the dataArray in struct is “nil”, which is same as the situation when I omit “dataArray” in json. However, I hope that the “dataArray” can be transferred as a 0-length slice like:
dataArray := make([]*data, 0)

So, is there any way to distinguish the two inputs for dataArray:
1.
{

“dataArray”: [ ]
}
2.
{

}

Thank you very much!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.