top of page

Groovy WMS script to convert object to JSON

  • thecodingguy
  • May 1
  • 1 min read

Updated: May 2

This is simplified version of a Groovy script I used on JDA / Blue Yonder WMS envs to map WMS data into an object and then use the Jackson ObjectMapper class to convert it to JSON. This is a very simplified version of the script.


A SQL could be added at the beginning, such as [select * from ord] and the result set passed into the script. Then the set methods can be changed to set the ORDNUM and WH_ID from the values in the SQL results.


More fields could also be added to the Order class as well to generate a more complex JSON.

[[

public class Order

{

private String ordnum;

private String wh_id;


public String getOrdnum() {

return this.ordnum;

}


public void setOrdnum( String ordnum ) {

this.ordnum = ordnum;

}

public String getWh_id() {

return this.wh_id;

}


public void setWh_id( String wh_id ) {

this.wh_id = wh_id;

}

}

import com.fasterxml.jackson.databind.ObjectMapper;


ObjectMapper mapper = new ObjectMapper();

Order ord = new Order();

ord.setOrdnum( "TEST_ORDER" );

ord.setWh_id( "TEST_WH_ID" );


String jsonString = mapper.writeValueAsString( ord );

//String jsonString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString( ord );

output_string = jsonString;

output_string;

]]

Recent Posts

See All
Groovy / MOCA for WMS KAFKA send

This is a Groovy script that can be used to send an XML message to a Kafka topic in a WMS env. I used it for testing sending to Kafka in...

 
 
Logo showing an abstract cartoon figure sitting in front of a laptop coding.  Next to the Logo is the text The Coding Guy

© 2025 by The Coding Guy, LLC

bottom of page