Trouble parsing JSON since it splits on the comma

Skip to first unread message

Devin Bost

Jul 29, 2020, 6:24:57 PM7/29/20
to jcommander
I'm working on a project that's reading a string message parameter like this:

@Parameter(names = { "-m", "--messages" },
= "Messages to send, either -m or -f or -j must be specified. The default separator is comma",
= NoSplitter.class)
private List<String> messages = Lists.newArrayList();

The NoSplitter class implements IParameterSplitter like this:

public class NoSplitter implements IParameterSplitter {
public List<String> split(final String value) {
final List<String> result = new LinkedList<>();
return result;

Unfortunately, whenever I pass a JSON message, such as:
'{ "testKey1": "testValue1", "testKey2": "testValue2" }'

The JSON gets split on the comma, resulting in two malformed JSON messages being received. 

I'm trying to find a solution that will allow me to pass a list of JSON objects, perhaps by allowing me to escape commas that I don't want the splitter to split on. 

Any suggestions? 



Cédric Beust ♔

Jul 29, 2020, 6:29:40 PM7/29/20
to jcommander

Hi Devin,

I’m a bit confused, I don’t see any mention of the comma in your NoSplitter class… How does this work?


You received this message because you are subscribed to the Google Groups "jcommander" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages