Salta al contenuto
Nessun risultato
  • Account
  • Articoli e libri
  • bbpress template
  • Calcolatrice legge di Ohm
  • Calcolatrici e convertitori
  • Convertitore Farad condensatori
  • Convertitore Ohm resistenze
  • Convertitore sistema numerico
  • Datasheet
  • Download
  • GeXY… Idea!
  • Login
  • Password Reset
  • Privacy e condizioni
  • Progetti
  • Video list
GeXY
Login/registrati
  • Progetti
  • Forum
  • Risorse
    • Datasheets
    • Calcolatrici & convertitori
    • Libri & articoli
    • Video
GeXY

OpenLab Developer

9
  • Implementare un logger storage
  • Creare un plugin base

OpenLab Studio Developer

7
  • Gestore degli errori
  • Schemi validazione configurazione
  • Elenco eventi standard
  • Logger standard
  • Logger base
  • Gestore degli eventi
  • Gestore della UI

GeJSON

3
  • Validazione json
  • Parsing json
  • Uso di GeJSON
View Categories
  • Home
  • OpenLab Docs
  • GeJSON
  • Parsing json

Parsing json

< 1 min read

GeJSON version 1.0.0
Linguaggi C#

Generale #

Questa guida mosta come trasformare una stringa che contiene una struttura json in una struttura di classi della libreria GeJSON.

Tipi di dati #

Json prevede un numero ridotto di tipi per i dati, in GeJSON i tipi verranno convertiti nel tipo nativo più adatto, quelli supportati sono:

  • Byte
  • String
  • Object
  • Array
  • Integer
  • Short
  • Long
  • Double
  • Float
  • Decimal

Uso base #

var jsonString = @"
{ 
    'name' : 'tommy ritommy', 
    'int' : 15, 
    'obj' : { 
        'key1' : 'Value1', 
        'key2' : 'Value2' 
    }, 
    'array' : [ 
        'string', 
        25, 
        101.5, 
        'objInArray' : [ '
            Inner string', 
            55 
        ] 
    ] 
}"; 
JObject o = new JObject(jsonString); 
Console.WriteLine(o.ToString());
Console.WriteLine(o.Get("obj").Get("key1"));

Notazione scientifica #

Sono ammessi numeri in notazione scientifica che verranno convertiti nel tipo numerico corretto. Per valutare il tipo, il dato viene trasformato nell’equivalente senza esponente. Per mantenere la notazione scientifica deve essere scritto come stringa, di seguito un esempio:

var jsonString = @"
{ 
    'number' : 150E02,
    'scientific number' : '150E02',
}"; 
JObject o = new JObject(jsonString); 
Console.WriteLine(o.ToString());

La proprietà scientific number non viene convertita in un numero, rimane una stringa, mentre number viene calcolata.

{
 "number": 15000,
 "scientific number": "150E02"
}

 

 

Updated on 20/09/2025

What are your Feelings

  • Happy
  • Normal
  • Sad

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest

Powered by BetterDocs

Table of Contents
  • Generale
  • Tipi di dati
  • Uso base
  • Notazione scientifica
Copyright © 2025 - Tema WordPress sviluppato da CreativeThemes