Using json with wpilib

Hi, I need to parse a json file coming in from the pynetwork tables on a Raspberry Pi. I’ve put the json into the table using something like:

temp_entry = []
temp_entry.append({"label": labelMap[detection.label], "confidence%": int(detection.confidence * 100)})
entry.setString(json.dumps(temp_entry))

Now I need to get it out on the WPI java program end. Has anyone used json in WPILib program?

import org.json.simple.JSONValue;

gives a compile error, since it can’t find org.json. How can I import this?
Thank you.

WPILib depends on Jackson, so you can use that for JSON processing. But if you want to use a different library you can, you just need to add the appropriate dependencies to build.gradle to pull it in.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.