Json ClassCastException无法将Object强制转换为mjson.Json

时间:2017-08-13 12:44:07

标签: java

请记住,我是netbeans和java的新手。它正在编译,但在运行中遇到上述错误。

  

错误:线程“main”中的异常java.lang.ClassCastException:java.lang.Object无法强制转换为mjson.Json

错误抛向我

package javaapplication1;

import mjson.Json;


public class JavaApplication1 {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    String jsonStr = 
            "{" +
            "\"firstName\":\"John\"," +
            "\"lastName\": \"Smith\"," +
            "\"isAlive\": true," +
            "\"age\": 25,"+
            "\"address\":" +
            "{"+
            "\"streetAddress\": \"21 2nd Street\","+
            "\"city\": \"New York\"," +
            "\"state\" \"NY\"," +
            "\"postalCode\": \"10021-3100\"" +
            "}," +
            "\"phoneNumbers\":"+
            "[" +
            "{" +
            "\"type\": \"home\"," +
            "\"number\": \"212 555-1234\"" +
            "},"+
            "{" +
            "\"type\":\"office\"," +
            "\"number\" : \"646 555-4567\"" +
            "}" +
            "]," +
            "\"children\" : [],"+
            "\"spouse\" : null" +
            "}";
      Json json =Json.read(jsonStr);

    System.out.print(jsonStr);

 }

}

0 个答案:

没有答案