Visualizzazione dei risultati da 1 a 1 su 1
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2016
    Messaggi
    6

    webservice c# con stringa json

    Salve ho realizzato un wbservice c# che leggendo dati da database restituisce una stringa json soltanto che la stringa restituita pur acendo la struttura json contiene intestazione xml come posso non farli comparire il codice è tipo questo sotto indicato

    codice:
    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string getData()
    {
        JavaScriptSerializer ser = new JavaScriptSerializer();
    
        var jsonData = new
        {
            total = 1, // we'll implement later 
            page = 1,
            records = 3, // implement later 
            rows = new[]{
              new {id = 1, cell = new[] {"1", "-7", "aa", "bb"}},
              new {id = 2, cell = new[] {"2", "15", "cc", "dd"}},
              new {id = 3, cell = new[] {"3", "23", "ff", "gg"}}
            }
        };
    
        return ser.Serialize(jsonData); //products.ToString();
    }

    codice:
    <?xml version="1.0" encoding="utf-8" ?> 
    <string  mlns="http://tempuri.org/">
    {
      "total":1,
      "page":1,
      "records":3,
      "rows":
        [
          {"id":1,"cell":["1","-7","aa","bb"]},
          {"id":2,"cell":["2","15","cc","dd"]},
          {"id":3,"cell":["3","23","ff","gg"]}
        ]
    }
    </string>
    Ultima modifica di LeleFT; 10-04-2017 a 10:47 Motivo: Aggiunti i tag CODE

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.