Skip to content

JSON split batch #5830

Closed Answered by pacmano1
parkinsonr asked this question in Q&A
Jun 26, 2023 · 4 comments · 6 replies
Discussion options

You must be logged in to vote

Your JSON example file is not valid JSON, you have an extra comma at the end, please take the time to make sure sample files you post are correct.

Put this code in the splitter whiich is almost verbatim from a post by @narupley at the forums, please do check there in the future.

var queue = $gc('queue');
if (!queue) {
	queue = new java.util.LinkedList();
	var obj = JSON.parse(org.apache.commons.io.IOUtils.toString(reader));
	for each (row in obj.DATA) {
		queue.add(JSON.stringify(row));
	}
	$gc('queue', queue);
}

var message = queue.poll();
if (!message) {
	globalChannelMap.remove('queue');
}
return message;

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@parkinsonr
Comment options

@pacmano1
Comment options

@parkinsonr
Comment options

@pacmano1
Comment options

Answer selected by parkinsonr
@parkinsonr
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants