Skip to content

Commit 39c2017

Browse files
committed
Fix JSON category field name.
1 parent 5f918ef commit 39c2017

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/java/boundingboxeditor/model/io/JSONLoadStrategy.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import java.util.stream.Collectors;
2323

2424
public class JSONLoadStrategy implements ImageAnnotationLoadStrategy {
25-
private static final String OBJECT_CATEGORY_SERIALIZED_NAME = "name";
25+
private static final String OBJECT_CATEGORY_NAME_SERIALIZED_NAME = "name";
26+
private static final String OBJECT_CATEGORY_SERIALIZED_NAME = "category";
2627
private static final String OBJECT_COLOR_SERIALIZED_NAME = "color";
2728
private static final String IMAGE_META_DATA_SERIALIZED_NAME = "image";
2829
private static final String BOUNDING_SHAPE_DATA_SERIALIZED_NAME = "objects";
@@ -212,15 +213,15 @@ public ObjectCategory deserialize(JsonElement json, java.lang.reflect.Type type,
212213
JsonDeserializationContext context) throws JsonParseException {
213214
final JsonObject jsonObject = json.getAsJsonObject();
214215

215-
if(!jsonObject.has(OBJECT_CATEGORY_SERIALIZED_NAME)) {
216+
if(!jsonObject.has(OBJECT_CATEGORY_NAME_SERIALIZED_NAME)) {
216217
unParsedFileErrorMessages
217218
.add(new IOResult.ErrorInfoEntry(annotationFileName,
218219
MISSING_CATEGORY_NAME_ERROR_MESSAGE + currentFilename.get() +
219220
"."));
220221
return null;
221222
}
222223

223-
final String categoryName = jsonObject.get(OBJECT_CATEGORY_SERIALIZED_NAME).getAsString();
224+
final String categoryName = jsonObject.get(OBJECT_CATEGORY_NAME_SERIALIZED_NAME).getAsString();
224225

225226
Color categoryColor;
226227

@@ -431,7 +432,7 @@ public BoundingBoxData deserialize(JsonElement json, java.lang.reflect.Type type
431432
JsonDeserializationContext context) throws JsonParseException {
432433
final JsonObject jsonObject = json.getAsJsonObject();
433434

434-
if(!jsonObject.has(OBJECT_CATEGORY_SERIALIZED_NAME)) {
435+
if(!jsonObject.has("category")) {
435436
unParsedFileErrorMessages.add(new IOResult.ErrorInfoEntry(annotationFileName,
436437
BOX_MISSING_CATEGORY_ERROR_MESSAGE +
437438
currentFileName.get() + "."));

0 commit comments

Comments
 (0)