Link to home
Start Free TrialLog in
Avatar of dy211
dy211

asked on

How do I validate JSON using C#/Xunit?

After spending two days of research on the simple validation of XML in Xunit (since noone was willing to help with my previous XML validating question), I've finally by myself written a very simple XML syntax validation code in C#. (code SIMPLIFIED EVEN FURTHER below)

Now I am faced with the same problem but this time is validation of JSON.

Please consider the code below and help me with write a simple and straight-forward solution just like the XML validation.

THANKS.


PS, I apologize if I sound a tad rude in my question, but I am losing patient with this PAID website.
using System;
using Xunit;
using System.Xml;
 
public class XMLisValid 
{
    [Fact]
    public void testXMLValid(string source) 
    {
        XmlDocument doc = new XmlDocument();
 
       Assert.DoesNotThrow(
                delegate
                {
                    doc.Load(source);
                });   
    }
}

Open in new window

SOLUTION
Avatar of MogalManic
MogalManic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial