Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme示例修正 #3

Open
ZhouXiaoLiu opened this issue Aug 21, 2023 · 1 comment
Open

readme示例修正 #3

ZhouXiaoLiu opened this issue Aug 21, 2023 · 1 comment

Comments

@ZhouXiaoLiu
Copy link

module tb;
    initial begin
        JSONValue jv;
        //json_test ts;

        //ts = new();
        jv = new();

        //ts.run_test();
        
        jv.loads({
        " { ",
        "\"n\" : null , ",
        "\"f\" : false , ",
        "\"t\" : true , ", 
        "\"i\" : 123 , ",
        "\"s\" : \"abc\", ",
        "\"a\" : [ 1, 2, 3 ],",
        "\"o\" : { \"1\" : 1, \"2\" : 2, \"3\" : 3 }",
        " } "});
        
        assert(7 == jv.getObjectSize()); // get 7 members in object
        assert(JSONValue::JSON_NULL   == jv.getObjectMember("n").getType()); // get null with key "n"
        assert(JSONValue::JSON_FALSE  == jv.getObjectMember("f").getType()); // get false with key "f"
        assert(JSONValue::JSON_TRUE   == jv.getObjectMember("t").getType()); // get true with key "t"
        assert(JSONValue::JSON_NUMBER == jv.getObjectMember("i").getType()); // get number with key "i"
        assert(JSONValue::JSON_STRING == jv.getObjectMember("s").getType()); // get string with key "s"
        assert(JSONValue::JSON_ARRAY  == jv.getObjectMember("a").getType()); // get array with key "a"
        assert(JSONValue::JSON_OBJECT == jv.getObjectMember("o").getType()); // get object with key "o"
    end
endmodule
@zhouchuanrui
Copy link
Owner

zhouchuanrui commented Aug 21, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants