0

the json file:

// config
{
    "is_train" : false,
    "train" : {
        "train_data" : "data.txt",
        "save_model_path" : "svm_model.yaml", 
        "SVM" : {
            "term_crit" : {
                "method" : 1,
                "iter" : 1000,
                "eps" : 1e-6
            }, 
            "type" : 100,
            "kernel_type" : 0,
            "Cvalue" : 0.1,
            "degree" : 0,
            "gamma" : 0,
            "coef0" : 0,
            "nu" : 0,
            "p" : 0,
            "class_weights" : 0,
        }
    },

    "predict" : {
        "SVM" : {
            "model" : "save_model.yaml",
            "test_data" : "test_data.txt",
            "test_ans" : "test_out.txt"
        }
    }
}

The problem is when I put "predict" in the front of "train", the params in "predict" can be parsed well,

value["predict"].isNull() will return false.

but "train" can't. And vice versa.

So how can I parse both correctly?

hgaolbb
  • 1
  • 1
  • 1
    It looks like the `"class_weights" : 0,` line in the `train` object should _not_ have a trailing comma, since there is no following field after that line. – Castaglia Apr 18 '16 at 06:33
  • If there is no trailing comma after `"class_weights"`, jsoncpp will not parse the json file. I really don't understand jsoncpp. thank you a lot. – hgaolbb Apr 19 '16 at 00:55
  • I've solved it! I've downloaded the newest version and compiled, and then modify the json file according to your advice. Thank you! – hgaolbb Apr 19 '16 at 01:44

0 Answers0