Example usage for jdk.nashorn.internal.parser JSONParser JSONParser

List of usage examples for jdk.nashorn.internal.parser JSONParser JSONParser

Introduction

In this page you can find the example usage for jdk.nashorn.internal.parser JSONParser JSONParser.

Prototype

JSONParser

Source Link

Usage

From source file:assigment2.CourseTest.java

    @Test
    public void testToString() {
        try {//  w  w w  . j  a va2 s .  com
            Student instance = new Student("Bill Smith", "c0123456", "male", 89.3);
            JSONObject expResult = (JSONObject) new JSONParser().parse("{\"name\":\"Bill Smith\",\"id\":\"c0123456\"},\"gender\":\"male\",\"grade\":\"89.3}");
            JSONObject result = (JSONObject) new JSONParser().parse(instance.toString());
            assertEquals(expResult, result);
        } catch (ParseException ex) {
            fail("One of the JSON Objects is invalid JSON. Go to jsonlint.com to find out why.");
        }
    
    
    
    
    
    

    
}