Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: Detect Network / VPN Connection Part 2 Pin
Richard MacCutchan15-Nov-18 10:54
mveRichard MacCutchan15-Nov-18 10:54 
GeneralRe: Detect Network / VPN Connection Part 2 Pin
Kevin Marois15-Nov-18 11:07
professionalKevin Marois15-Nov-18 11:07 
AnswerRe: Detect Network / VPN Connection Part 2 Pin
Nitin S28-Dec-18 1:34
professionalNitin S28-Dec-18 1:34 
QuestionHow to copy also subfolders and their files from an certain folder? Pin
Member 1405587915-Nov-18 4:24
Member 1405587915-Nov-18 4:24 
QuestionRe: How to copy also subfolders and their files from an certain folder? Pin
Richard MacCutchan15-Nov-18 6:04
mveRichard MacCutchan15-Nov-18 6:04 
AnswerRe: How to copy also subfolders and their files from an certain folder? Pin
Luc Pattyn15-Nov-18 8:01
sitebuilderLuc Pattyn15-Nov-18 8:01 
QuestionParsing JSon Pin
pkfox15-Nov-18 3:57
professionalpkfox15-Nov-18 3:57 
AnswerRe: Parsing JSon Pin
OriginalGriff15-Nov-18 4:13
mveOriginalGriff15-Nov-18 4:13 
The first thing to note is that there are three problems with the JSON data:
1) Remove the introductory "crossword"
2) Remove the trailing "headwordcrossword"
3) Escape the double quotes in the "audiofile" href:
HTML
"audioFile": "<a href="http://audio.oxforddictionaries.com/en/mp3/crossword_gb_1_8.mp3">http://audio.oxforddictionaries.com/en/mp3/crossword_gb_1_8.mp3</a>",
To:
HTML
"audioFile": "<a href=\"http://audio.oxforddictionaries.com/en/mp3/crossword_gb_1_8.mp3\">http://audio.oxforddictionaries.com/en/mp3/crossword_gb_1_8.mp3</a>",


When you do that, it'll parse fine.

There is an online JSON to C# class converter I use: json2csharp - generate c# classes from json[^] which gives me these classes:
C#
public class GrammaticalFeature
{
    public string text { get; set; }
    public string type { get; set; }
}

public class Example
{
    public string text { get; set; }
}

public class Sens
{
    public List<string> definitions { get; set; }
    public List<string> domains { get; set; }
    public List<Example> examples { get; set; }
    public string id { get; set; }
    public List<string> short_definitions { get; set; }
}

public class VariantForm
{
    public string text { get; set; }
}

public class Entry
{
    public List<string> etymologies { get; set; }
    public List<GrammaticalFeature> grammaticalFeatures { get; set; }
    public string homographNumber { get; set; }
    public List<Sens> senses { get; set; }
    public List<VariantForm> variantForms { get; set; }
}

public class Pronunciation
{
    public string audioFile { get; set; }
    public List<string> dialects { get; set; }
    public string phoneticNotation { get; set; }
    public string phoneticSpelling { get; set; }
}

public class RootObject
{
    public List<Entry> entries { get; set; }
    public string language { get; set; }
    public string lexicalCategory { get; set; }
    public List<Pronunciation> pronunciations { get; set; }
    public string text { get; set; }
}
Add those to your app, and try Newtonsoft JSOn parser - it should be a single line of code! Json.NET - Newtonsoft[^]
Give it a try - it normally works very nicely for me!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Parsing JSon Pin
pkfox15-Nov-18 4:22
professionalpkfox15-Nov-18 4:22 
GeneralRe: Parsing JSon Pin
pkfox15-Nov-18 5:10
professionalpkfox15-Nov-18 5:10 
GeneralRe: Parsing JSon Pin
OriginalGriff15-Nov-18 5:27
mveOriginalGriff15-Nov-18 5:27 
GeneralRe: Parsing JSon Pin
OriginalGriff15-Nov-18 5:42
mveOriginalGriff15-Nov-18 5:42 
GeneralRe: Parsing JSon Pin
pkfox15-Nov-18 22:23
professionalpkfox15-Nov-18 22:23 
GeneralRe: Parsing JSon Pin
OriginalGriff15-Nov-18 22:31
mveOriginalGriff15-Nov-18 22:31 
GeneralRe: Parsing JSon Pin
pkfox15-Nov-18 22:38
professionalpkfox15-Nov-18 22:38 
GeneralRe: Parsing JSon Pin
OriginalGriff15-Nov-18 23:03
mveOriginalGriff15-Nov-18 23:03 
GeneralRe: Parsing JSon Success Pin
pkfox15-Nov-18 23:19
professionalpkfox15-Nov-18 23:19 
GeneralRe: Parsing JSon Success Pin
OriginalGriff15-Nov-18 23:37
mveOriginalGriff15-Nov-18 23:37 
GeneralRe: Parsing JSon Success Pin
pkfox15-Nov-18 23:39
professionalpkfox15-Nov-18 23:39 
GeneralRe: Parsing JSon Success Pin
pkfox16-Nov-18 2:57
professionalpkfox16-Nov-18 2:57 
QuestionGuys need your help am trying to insert data in MS Access database but its giving me a "Syntax Error" and i cnt find the problem....please analyse it and help Pin
Member 1405572615-Nov-18 2:09
Member 1405572615-Nov-18 2:09 
AnswerRe: Guys need your help am trying to insert data in MS Access database but its giving me a "Syntax Error" and i cnt find the problem....please analyse it and help Pin
OriginalGriff15-Nov-18 2:17
mveOriginalGriff15-Nov-18 2:17 
AnswerRe: Guys need your help am trying to insert data in MS Access database but its giving me a "Syntax Error" and i cnt find the problem....please analyse it and help Pin
Member 1332584615-Nov-18 21:00
Member 1332584615-Nov-18 21:00 
QuestionTo MD5 or not? (or SHA256 instead, I guess...) Pin
Super Lloyd14-Nov-18 15:34
Super Lloyd14-Nov-18 15:34 
AnswerRe: To MD5 or not? (or SHA256 instead, I guess...) PinPopular
Dave Kreskowiak14-Nov-18 16:37
mveDave Kreskowiak14-Nov-18 16:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.