Paul Cohen Paul Cohen - 4 months ago 33 Question

Read DropBox info.json file with .NetJSON

Any ideas, I don't understand the Object I need to define. I am coding in VB but C# is OK. The file is one line but seems to have some nesting with Personal and Business.

{"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"}}

dbc dbc

You can define your classes as follows:

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

Then deserialize as follows:

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

Example fiddle. Related documentation: How can I programmatically find the Dropbox folder paths?.