2016-05-29 5 views
1

Alle Ideen, ich verstehe nicht das Objekt, das ich definieren muss. Ich bin in VB codieren, aber C# ist in Ordnung. Die Datei ist eine Zeile, scheint aber mit Personal und Business verschachtelt zu sein.Lesen DropBox info.json Datei mit. NetJSON

{ 
    "personal": { 
    "path": "C:\\Users\\Paul\\Dropbox (Personal)", 
    "host": 4897400149, 
    "is_team": false, 
    "subscription_type": "Basic" 
    }, 
    "business": { 
    "path": "C:\\Users\\Paul\\Dropbox (Y2016)", 
    "host": 4897401185, 
    "is_team": true, 
    "subscription_type": "Business" 
    } 
} 
+0

{"personal": {"Pfad": "C: \\ Benutzer \\ Paul \\ Dropbox (Personal)", "host": 4897400149, "is_team": false, "subscription_type": "Basic"} , "business": {"Pfad": "C: \\ Benutzer \\ Paul \\ Dropbox (YEA2016)", "Host": 4897401185, "is_team": true, "subscription_type": "Geschäft"}} ist eigentlich Was ist in der Datei? Mein Redakteur entfloh ihm. –

Antwort

1

Sie können Ihre Klassen wie folgt definieren:

Public Class DropBoxFolderPath 
    Public Property path As String 
    Public Property host As Long 
    Public Property is_team As Boolean 
    Public Property subscription_type As String 
End Class 

Public Class DropBoxFolderPaths 
    Public Property personal As DropBoxFolderPath 
    Public Property business As DropBoxFolderPath 
End Class 

Dann deserialisieren wie folgt:

Dim dropBoxFolders = JsonConvert.DeserializeObject(Of DropBoxFolderPaths)(jsonString) 

Beispiel fiddle. Verwandte Dokumentation: How can I programmatically find the Dropbox folder paths?.