Skip to content

Commit

Permalink
Added ignore on unknown properties.
Browse files Browse the repository at this point in the history
Signed-off-by: thenetworkgrinch <thenetworkgrinch@users.noreply.github.com>
  • Loading branch information
thenetworkgrinch committed Jan 8, 2025
1 parent 25dca8c commit 3599c91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/deploy/swerve/neo/swervedrive.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/swervedrive_schema.json",
"imu": {
"type": "pigeon2",
"id": 13,
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/swervelib/parser/SwerveParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package swervelib.parser;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.wpi.first.math.geometry.Pose2d;
Expand Down Expand Up @@ -57,17 +58,21 @@ public SwerveParser(File directory) throws IOException
checkDirectory(directory);
swerveDriveJson =
new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.readValue(new File(directory, "swervedrive.json"), SwerveDriveJson.class);
controllerPropertiesJson =
new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.readValue(
new File(directory, "controllerproperties.json"), ControllerPropertiesJson.class);
pidfPropertiesJson =
new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.readValue(
new File(directory, "modules/pidfproperties.json"), PIDFPropertiesJson.class);
physicalPropertiesJson =
new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.readValue(
new File(directory, "modules/physicalproperties.json"),
PhysicalPropertiesJson.class);
Expand All @@ -77,7 +82,9 @@ public SwerveParser(File directory) throws IOException
moduleConfigs.put(swerveDriveJson.modules[i], i);
File moduleFile = new File(directory, "modules/" + swerveDriveJson.modules[i]);
assert moduleFile.exists();
moduleJsons[i] = new ObjectMapper().readValue(moduleFile, ModuleJson.class);
moduleJsons[i] = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.readValue(moduleFile, ModuleJson.class);
}
}

Expand Down

0 comments on commit 3599c91

Please sign in to comment.