JavaScriptSerializer Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Para .NET Framework 4.7.2 e versões posteriores, utilize as APIs no espaço de nomes System.Text.Json para serialização e desserialização. Para versões anteriores do .NET Framework, use Newtonsoft.Json. Este tipo destinava-se a fornecer funcionalidade de serialização e desserialização para aplicações com suporte ao AJAX.
public ref class JavaScriptSerializer
public class JavaScriptSerializer
type JavaScriptSerializer = class
Public Class JavaScriptSerializer
- Herança
-
JavaScriptSerializer
Exemplos
O primeiro exemplo fornece uma ilustração simples de como serializar e desserializar objetos de dados. Requer uma classe chamada Pessoa, que é mostrada abaixo.
using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.Script.Serialization;
namespace ExampleApplication
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
var RegisteredUsers = new List<Person>();
RegisteredUsers.Add(new Person() { PersonID = 1, Name = "Bryon Hetrick", Registered = true });
RegisteredUsers.Add(new Person() { PersonID = 2, Name = "Nicole Wilcox", Registered = true });
RegisteredUsers.Add(new Person() { PersonID = 3, Name = "Adrian Martinson", Registered = false });
RegisteredUsers.Add(new Person() { PersonID = 4, Name = "Nora Osborn", Registered = false });
var serializer = new JavaScriptSerializer();
var serializedResult = serializer.Serialize(RegisteredUsers);
// Produces string value of:
// [
// {"PersonID":1,"Name":"Bryon Hetrick","Registered":true},
// {"PersonID":2,"Name":"Nicole Wilcox","Registered":true},
// {"PersonID":3,"Name":"Adrian Martinson","Registered":false},
// {"PersonID":4,"Name":"Nora Osborn","Registered":false}
// ]
var deserializedResult = serializer.Deserialize<List<Person>>(serializedResult);
// Produces List with 4 Person objects
}
}
}
Imports System.Web.Script.Serialization
Public Class _Default
Inherits Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim RegisteredUsers As New List(Of Person)()
RegisteredUsers.Add(New Person With {.PersonID = 1, .Name = "Bryon Hetrick", .Registered = True})
RegisteredUsers.Add(New Person With {.PersonID = 2, .Name = "Nicole Wilcox", .Registered = True})
RegisteredUsers.Add(New Person With {.PersonID = 3, .Name = "Adrian Martinson", .Registered = False})
RegisteredUsers.Add(New Person With {.PersonID = 4, .Name = "Nora Osborn", .Registered = False})
Dim serializer As New JavaScriptSerializer()
Dim serializedResult = serializer.Serialize(RegisteredUsers)
' Produces string value of:
' [
' {"PersonID":1,"Name":"Bryon Hetrick","Registered":true},
' {"PersonID":2,"Name":"Nicole Wilcox","Registered":true},
' {"PersonID":3,"Name":"Adrian Martinson","Registered":false},
' {"PersonID":4,"Name":"Nora Osborn","Registered":false}
' ]
Dim deserializedResult = serializer.Deserialize(Of List(Of Person))(serializedResult)
' Produces List with 4 Person objects
End Sub
End Class
namespace ExampleApplication
{
public class Person
{
public int PersonID { get; set; }
public string Name { get; set; }
public bool Registered { get; set; }
}
}
Public Class Person
Public Property PersonID As Integer
Public Property Name As String
Public Property Registered As Boolean
End Class
O próximo exemplo mostra um projeto mais complicado e completo que usa a JavaScriptSerializer classe para guardar e restaurar o estado de um objeto usando serialização JSON. Este código utiliza um conversor personalizado fornecido para a JavaScriptConverter classe.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
JavaScriptSerializer serializer;
protected void Page_Load(object sender, EventArgs e)
{
//<Snippet1>
serializer = new JavaScriptSerializer();
// Register the custom converter.
serializer.RegisterConverters(new JavaScriptConverter[] {
new System.Web.Script.Serialization.CS.ListItemCollectionConverter() });
//</Snippet1>
this.SetFocus(TextBox1);
}
protected void saveButton_Click(object sender, EventArgs e)
{
// Save the current state of the ListBox control.
SavedState.Text = serializer.Serialize(ListBox1.Items);
recoverButton.Enabled = true;
Message.Text = "State saved";
}
protected void recoverButton_Click(object sender, EventArgs e)
{
//Recover the saved items of the ListBox control.
ListItemCollection recoveredList = serializer.Deserialize<ListItemCollection>(SavedState.Text);
ListItem[] newListItemArray = new ListItem[recoveredList.Count];
recoveredList.CopyTo(newListItemArray, 0);
ListBox1.Items.Clear();
ListBox1.Items.AddRange(newListItemArray);
Message.Text = "Last saved state recovered.";
}
protected void clearButton_Click(object sender, EventArgs e)
{
// Remove all items from the ListBox control.
ListBox1.Items.Clear();
Message.Text = "All items removed";
}
protected void ContactsGrid_SelectedIndexChanged(object sender, EventArgs e)
{
// Get the currently selected row using the SelectedRow property.
GridViewRow row = ContactsGrid.SelectedRow;
// Get the ID of item selected.
string itemId = ContactsGrid.DataKeys[row.RowIndex].Value.ToString();
ListItem newItem = new ListItem(row.Cells[4].Text, itemId);
// Check if the item already exists in the ListBox control.
if (!ListBox1.Items.Contains(newItem))
{
// Add the item to the ListBox control.
ListBox1.Items.Add(newItem);
Message.Text = "Item added";
}
else
Message.Text = "Item already exists";
}
protected void ContactsGrid_PageIndexChanged(object sender, EventArgs e)
{
//Reset the selected index.
ContactsGrid.SelectedIndex = -1;
}
protected void searchButton_Click(object sender, EventArgs e)
{
//Reset indexes.
ContactsGrid.SelectedIndex = -1;
ContactsGrid.PageIndex = 0;
//Set focus on the TextBox control.
ScriptManager1.SetFocus(TextBox1);
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
// Show/hide the saved state string.
SavedState.Visible = CheckBox1.Checked;
StateLabel.Visible = CheckBox1.Checked;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Save/Recover state</title>
<style type="text/css">
body { font: 11pt Trebuchet MS;
font-color: #000000;
padding-top: 72px;
text-align: center }
.text { font: 8pt Trebuchet MS }
</style>
</head>
<body>
<form id="form1" runat="server" defaultbutton="searchButton" defaultfocus="TextBox1">
<h3>
<span style="text-decoration: underline">
Contacts Selection</span><br />
</h3>
<asp:ScriptManager runat="server" ID="ScriptManager1" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Type contact's first name:
<asp:TextBox ID="TextBox1" runat="server" />
<asp:Button ID="searchButton" runat="server" Text="Search" OnClick="searchButton_Click" />
<br />
<br />
<table border="0" width="100%">
<tr>
<td style="width:50%" valign="top" align="center">
<b>Search results:</b><br />
<asp:GridView ID="ContactsGrid" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ContactID" DataSourceID="SqlDataSource1"
OnSelectedIndexChanged="ContactsGrid_SelectedIndexChanged" ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="7" OnPageIndexChanged="ContactsGrid_PageIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True" ButtonType="Button" />
<asp:BoundField DataField="ContactID" HeaderText="ContactID" SortExpression="ContactID" Visible="False" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress" SortExpression="EmailAddress" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<EmptyDataTemplate>No data found.</EmptyDataTemplate>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
SelectCommand="SELECT ContactID, FirstName, LastName, EmailAddress FROM Person.Contact WHERE (UPPER(FirstName) = UPPER(@FIRSTNAME))" >
<SelectParameters>
<asp:ControlParameter Name="FIRSTNAME" ControlId="TextBox1" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
<td valign="top">
<b>Contacts list:</b><br />
<asp:ListBox ID="ListBox1" runat="server" Height="200px" Width="214px" /><br />
<asp:Button ID="saveButton" runat="server" Text="Save state" OnClick="saveButton_Click" ToolTip="Save the current state of the list" />
<asp:Button ID="recoverButton" runat="server" Text="Recover saved state" OnClick="recoverButton_Click" Enabled="false" ToolTip="Recover the last saved state" />
<asp:Button ID="clearButton" runat="server" Text="Clear" OnClick="clearButton_Click" ToolTip="Remove all items from the list" /><br />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Checked="True" OnCheckedChanged="CheckBox1_CheckedChanged"
Text="Show saved state" AutoPostBack="True" /></td>
</tr>
<tr>
<td colspan="2">
<br />
<br />
<hr />
Message: <asp:Label ID="Message" runat="server" ForeColor="SteelBlue" /> <br />
<asp:Label ID="StateLabel" runat="server" Text="State:"></asp:Label>
<asp:Label ID="SavedState" runat="server"/><br />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="..\images\spinner.gif" /> Processing...
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim serializer As JavaScriptSerializer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'<Snippet1>
serializer = New JavaScriptSerializer()
' Register the custom converter.
serializer.RegisterConverters(New JavaScriptConverter() _
{New System.Web.Script.Serialization.VB.ListItemCollectionConverter()})
'</Snippet1>
End Sub
Protected Sub saveButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Save the current state of the ListBox control.
SavedState.Text = serializer.Serialize(ListBox1.Items)
recoverButton.Enabled = True
Message.Text = "State saved"
End Sub
Protected Sub recoverButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Recover the saved items of the ListBox control.
Dim recoveredList As ListItemCollection = _
serializer.Deserialize(Of ListItemCollection)(SavedState.Text)
Dim newListItemArray(recoveredList.Count - 1) As ListItem
recoveredList.CopyTo(newListItemArray, 0)
ListBox1.Items.Clear()
ListBox1.Items.AddRange(newListItemArray)
Message.Text = "Last saved state recovered."
End Sub
Protected Sub clearButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Remove all items from the ListBox control.
ListBox1.Items.Clear()
Message.Text = "All items removed"
End Sub
Protected Sub ContactsGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
' Get the currently selected row using the SelectedRow property.
Dim row As GridViewRow = ContactsGrid.SelectedRow
' Get the ID of the item selected.
Dim itemId As String = ContactsGrid.DataKeys(row.RowIndex).Value.ToString()
Dim newItem As ListItem = New ListItem(row.Cells(4).Text, itemId)
' Check if the item already exists in the ListBox control.
If Not ListBox1.Items.Contains(newItem) Then
' Add the item to the ListBox control.
ListBox1.Items.Add(newItem)
Message.Text = "Item added"
Else
Message.Text = "Item already exists"
End If
End Sub
Private Function SearchItem(ByVal itemId As String) As Boolean
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).Value = itemId Then
Return True
End If
Next i
Return False
End Function
Protected Sub ContactsGrid_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
ContactsGrid.SelectedIndex = -1
End Sub
Protected Sub searchButton_Click(ByVal sender As Object, ByVal e As EventArgs)
ContactsGrid.SelectedIndex = -1
ContactsGrid.PageIndex = 0
ScriptManager1.SetFocus(TextBox1)
End Sub
Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
SavedState.Visible = CheckBox1.Checked
StateLabel.Visible = CheckBox1.Checked
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Save/Recover state</title>
<style type="text/css">
body { font: 11pt Trebuchet MS;
font-color: #000000;
padding-top: 72px;
text-align: center }
.text { font: 8pt Trebuchet MS }
</style>
</head>
<body>
<form id="form1" runat="server" defaultbutton="searchButton" defaultfocus="TextBox1">
<h3>
<span style="text-decoration: underline">
Contacts Selection</span><br />
</h3>
<asp:ScriptManager runat="server" ID="ScriptManager1" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Type contact's first name:
<asp:TextBox ID="TextBox1" runat="server" />
<asp:Button ID="searchButton" runat="server" Text="Search" OnClick="searchButton_Click" />
<br />
<br />
<table border="0" width="100%">
<tr>
<td style="width:50%" valign="top" align="center">
<b>Search results:</b><br />
<asp:GridView ID="ContactsGrid" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ContactID" DataSourceID="SqlDataSource1"
OnSelectedIndexChanged="ContactsGrid_SelectedIndexChanged" ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="7" OnPageIndexChanged="ContactsGrid_PageIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True" ButtonType="Button" />
<asp:BoundField DataField="ContactID" HeaderText="ContactID" SortExpression="ContactID" Visible="False" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress" SortExpression="EmailAddress" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<EmptyDataTemplate>No data found.</EmptyDataTemplate>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
SelectCommand="SELECT ContactID, FirstName, LastName, EmailAddress FROM Person.Contact WHERE (UPPER(FirstName) = UPPER(@FIRSTNAME))" >
<SelectParameters>
<asp:ControlParameter Name="FIRSTNAME" ControlId="TextBox1" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
<td valign="top">
<b>Contacts list:</b><br />
<asp:ListBox ID="ListBox1" runat="server" Height="200px" Width="214px" /><br />
<asp:Button ID="saveButton" runat="server" Text="Save state" OnClick="saveButton_Click" ToolTip="Save the current state of the list" />
<asp:Button ID="recoverButton" runat="server" Text="Recover saved state" OnClick="recoverButton_Click" Enabled="false" ToolTip="Recover the last saved state" />
<asp:Button ID="clearButton" runat="server" Text="Clear" OnClick="clearButton_Click" ToolTip="Remove all items from the list" /><br />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Checked="True" OnCheckedChanged="CheckBox1_CheckedChanged"
Text="Show saved state" AutoPostBack="True" /></td>
</tr>
<tr>
<td colspan="2">
<br />
<br />
<hr />
Message: <asp:Label ID="Message" runat="server" ForeColor="SteelBlue" /> <br />
<asp:Label ID="StateLabel" runat="server" Text="State:"></asp:Label>
<asp:Label ID="SavedState" runat="server"/><br />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="..\images\spinner.gif" /> Processing...
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
</html>
Observações
Importante
Para .NET Framework 4.7.2 e versões posteriores, as APIs no espaço de nomes System.Text.Json devem ser usadas para serialização e desserialização. Para versões anteriores do .NET Framework, use Newtonsoft.Json.
A JavaScriptSerializer classe é usada internamente pela camada de comunicação assíncrona para serializar e desserializar os dados que são passados entre o navegador e o servidor Web. Não podes aceder a essa instância do serializador. No entanto, esta classe expõe uma API pública. Por isso, pode usar a classe quando quiser trabalhar com JavaScript Object Notation (JSON) em código gerido.
Para serializar um objeto, use o Serialize método. Para desserializar uma string JSON, use os Deserialize métodos ou.DeserializeObject Para serializar e desserializar tipos que não são suportados nativamente por JavaScriptSerializer, implemente conversores personalizados usando a JavaScriptConverter classe. Depois regista os conversores usando o RegisterConverters método.
Mapeamento entre tipos geridos e JSON
A tabela seguinte mostra o mapeamento entre tipos geridos e JSON para o processo de serialização. Estes tipos geridos são suportados nativamente por JavaScriptSerializer. Quando estás a desserializar de uma string JSON para um tipo gerido, aplica-se o mesmo mapeamento. No entanto, a desserialização pode ser assimétrica; nem todos os tipos geridos serializáveis podem ser desserializados a partir do JSON.
Note
Um array multidimensional é serializado como um array unidimensional, e deve usá-lo como um array plano.
| Tipo gerenciado | Equivalente a JSON |
|---|---|
| String (Apenas codificação UTF-8). | String |
| Char | String |
| Personagem nula única (como, \0) | Null |
| Boolean | Booleano. Representado em JSON como true ou false |
null (null referências a objetos e Nullable tipos de valor). |
Um valor de cadeia nulo |
| DBNull | Um valor de cadeia nulo |
| Tipos numéricos primitivos (ou compatíveis numericamente): Byte, SByte, Int16, Int32, Int64, UInt16DoubleUInt32UInt64e .Single A representação de cordas invariante em cultura é utilizada. | Número |
| DateTime | Objeto Data, representado em JSON como "\/Data(número de ticks)\/". O número de tiques é um valor longo positivo ou negativo que indica o número de tiques (milissegundos) que decorreram desde a meia-noite de 1 de janeiro de 1970 UTC. O valor máximo de data suportado é MaxValue (31/12/9999 11:59:59 PM) e o valor mínimo de data suportado é MinValue (1/1/0001 00:00). |
| Enumerações de tipo inteiro | Equivalente inteiro ao valor da enumeração |
| Tipos que implementam IEnumerable ou System.Collections.Generic.IEnumerable<T> que não são também implementações de IDictionary ou System.Collections.Generic.IDictionary<TKey,TValue>. Isto inclui tipos como Array, ArrayList, e List<T>. | Array que utiliza sintaxe de array JSON |
| Tipos que implementam IDictionary ou System.Collections.Generic.IDictionary<TKey,TValue>. Isto inclui tipos como Dictionary<TKey,TValue> e Hashtable. | Objeto JavaScript que utiliza a sintaxe do dicionário JSON |
| Tipos personalizados de concreto (não abstratos) que têm propriedades de instância pública que têm acessórios get ou campos de instância pública. Note que propriedades públicas apenas para escrita, propriedades públicas ou atributos de campo público marcados com ScriptIgnoreAttribute, e propriedades indexadas públicas nestes tipos são ignoradas. |
Objeto JavaScript que utiliza sintaxe de dicionário JSON. Uma propriedade especial de metadados chamada "__type" é incluída para garantir a correta desserialização. Certifique-se de que as propriedades públicas de instância têm acessórios de acesso e configuração para garantir a desserialização correta. |
| Guid | Representação de cadeias de um GUID |
| Uri | Representação da cadeia do valor de retorno de GetComponents |
Construtores
| Name | Description |
|---|---|
| JavaScriptSerializer() |
Inicializa uma nova instância da JavaScriptSerializer classe que não tem resolvedor de tipos. |
| JavaScriptSerializer(JavaScriptTypeResolver) |
Inicializa uma nova instância da JavaScriptSerializer classe que tem um resolvedor de tipos personalizado. |
Propriedades
| Name | Description |
|---|---|
| MaxJsonLength |
Obtém ou define o comprimento máximo das cadeias JSON aceites pela JavaScriptSerializer turma. |
| RecursionLimit |
Obtém ou define o limite para restringir o número de níveis de objeto a processar. |
Métodos
| Name | Description |
|---|---|
| ConvertToType(Object, Type) |
Converte o objeto especificado para o tipo especificado. |
| ConvertToType<T>(Object) |
Converte o objeto dado para o tipo especificado. |
| Deserialize(String, Type) |
Converte uma string formatada em JSON para um objeto do tipo especificado. |
| Deserialize<T>(String) |
Converte a cadeia JSON especificada num objeto do tipo |
| DeserializeObject(String) |
Converte a string JSON especificada num grafo de objetos. |
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
| GetHashCode() |
Serve como função de hash predefinida. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do atual Object. (Herdado de Object) |
| RegisterConverters(IEnumerable<JavaScriptConverter>) |
Regista um conversor personalizado com a JavaScriptSerializer instância. |
| Serialize(Object, StringBuilder) |
Serializa um objeto e escreve a string JSON resultante no objeto especificado StringBuilder . |
| Serialize(Object) |
Converte um objeto numa string JSON. |
| ToString() |
Devolve uma cadeia que representa o objeto atual. (Herdado de Object) |