I have a Checkbox with 7 different options that can be checked and used, amonst them things like range_close and component_type_stock, component_type_lostech.
I am now trying to write them via a json writer into a json file but if I use
writer.WritePropertyName("ComponentTags");
writer.WriteStartObject();
writer.WritePropertyName("items");
writer.WriteRawValue(ComponentTagsCheckBox.CheckedItems.ToString());
All I get is
"ComponentTags": {
"items": System.Windows.Forms.CheckedListBox+CheckedItemCollection,
When I have the range_extreme and component_type_lostech checkboxes marked in the checkbox.
I already tried using a for loop by replacing the last line in the previous code snippet
string s = "";
for (int x = 0; x <= ComponentTagsCheckBox.CheckedItems.Count - 1; x++)
{
s = s + ComponentTagsCheckBox.CheckedItems[x].ToString(); //+ "\n";
}
writer.WriteRawValue("["+ s +"]");
Here the output is at least
"ComponentTags": {
"items": [component_type_lostechrange_extreme],
"tagSetSourceFile": ""
}
But the output should be this
"ComponentTags" : {
"items" : [
"component_type_variant",
"component_type_variant2",
"range_extreme"
],
"tagSetSourceFile" : ""
I can do without it looking like the last snippet as long as the components are seperated by a semicolon and surrounded by "".
I also had an idea to split the string into an array and then seperate it again but that seems like a tad bit to much work.
Aucun commentaire:
Enregistrer un commentaire