CKTIS / C#
System.Text.Json.Nodes.JsonNode: referencia práctica
System.Text.Json.Nodes.JsonNode: referencia práctica: JsonNode representa un árbol JSON mutable de objetos, matrices y valores.
Versión: .NET API; verified against .NET 10 reference surface
Sintaxis
System.Text.Json.Nodes.JsonNode /* select a documented member or constructor */JsonNode representa un árbol JSON mutable de objetos, matrices y valores.
Úsalo para cambios puntuales de documentos sin un modelo estático.
Un nodo tiene un solo padre; reutilizarlo en otro lugar requiere un clon.
Parse puede devolver null para el literal null; acceder con el tipo incorrecto lanza una excepción.
El programa completo usa realmente System.Text.Json.Nodes.JsonNode; su stdout esperado exacto es 4.
Ejemplos
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var node = JsonNode.Parse("{\"x\":4}")!;
Console.WriteLine(node["x"]!.GetValue<int>());
Resultado
4
El programa completo usa realmente `System.Text.Json.Nodes.JsonNode`; su stdout esperado exacto es `4`.