How do I check if an answer in json comes empty from a webservice .svc?

0

I do a post from a form and when the json returns with the objects of a sql table it gives me without problems .. but when there is no data in the table and returns empty the json returns it to me badly formed example I want to control it for that I do not get errors like in the image

{"data:]"}

asked by emanuelle 10.02.2018 в 09:18
source

1 answer

0

I did an update today

    public Stream buscaPedim(string usuario, string estado, string buscarPor, string fecha_ini, string fecha_fin)
    {


        getPedimentos Pedimentos = new getPedimentos();
        string res = Pedimentos.consulta(usuario, estado, buscarPor, fecha_ini, fecha_fin);

        if (res != null)

            WebOperationContext.Current.OutgoingResponse.ContentType =
   "application/json; charset=utf-8";
        if (res == "")
        {
            //que puedo hacer aqui con el json vacio?
        }
        else 
        return new MemoryStream(Encoding.UTF8.GetBytes(res));
    }
    
answered by 10.02.2018 в 17:33