ich eine Anwendung, die config in folgenden JSON-Format erwartet, aber minimierte:zuordnen [null] in Json :: Wert in JsonCpp
<config-json>
{
"config" : {
"services" : {
"analytics" : {
"sensor" : [
{
"name" : "ip-sensor",
"server-name" : ["ip-server1"],
"export-name" : "ip-export1",
"resource" : "/ipv4",
"bulk" : [null] // <-- Notice
}
]
}
}
}
}
</config-json>
In der obigen JSON config die App erwartet "bulk"
als [null]
immer zu sein . Und das ist eine richtige Erwartung aus Sicht der App.
In meinem Config-Generator-Code verwende ich JsonCpp, um die JSON-Objekte mit Json::Value zu erstellen.
Da "bulk"
Bedürfnisse [null]
sein, ich bin bevölkern es wie folgt:
//Json::Value *json_obj //Getting passed as an arg
(*json_obj)["config"]["services"]["analytics"]["sensor"][0]["bulk"] = Json::nullValue;
Aber was ich bekommen ist:
"bulk":null // Notice the missing [] around null.
Und daher wird die Config verworfen.
Gibt es eine Möglichkeit in JsonCpp folgendes zu erreichen:
"bulk" : [null]
auch als '(* json_obj) [ "config"] [ "services"] [ "Analytik"] [ "Sensor"] verwendet werden kann [0] [ "Bulk"]. Append (Json :: Wert :: null); ' Nein? –