/** * \brief JSON Validator Example * * A JSON string is validated and the output is either * "valid" or "invalid". In this case the output is "valid". * *

* { "Product number" : 186189 , * "Product description": "After Eight 200gr" , * "In stock" : 52455 ; ' + * "Distribution lock" : False , * "Cost" = 1.235 , * "Supplier" = 358 , * "Category" = { "Id" : 15 , "Description": "Sweets"}, * "Product line" : [ * {"Sweets" = "120.1.1." } , * {"Chocolate" = "120.1.2" } , ] , * "Assigned stocks" = [ ] , * "Assigned display" = {} , * } *

* * On invalid code the invalid position stated in the joblog. * * \author Mihael Schmidt * \date 13.03.2009 */ H DFTACTGRP(*NO) ACTGRP(*CALLER) *------------------------------------------------------------------------ * Prototypes *------------------------------------------------------------------------ /include 'json/json_h.rpgle' *------------------------------------------------------------------------ * Variables *------------------------------------------------------------------------ D json_string S 65535A /free json_string = '{' + '"Product number" : 186189 , ' + '"Product description": "After Eight 200gr" , ' + '"In stock" : 52455 , ' + '"Distribution lock" : false , ' + '"Cost" : 1.235 , ' + '"Supplier" : 358 , ' + '"Category" : { "Id" : 15 , "Description": "Sweets"}, ' + '"Product line" : [ ' + '{"Sweets" : "120.1.1." } , ' + '{"Chocolate" : "120.1.2" } ' + '] , ' + '"Assigned stocks" : [ ] ,' + '"Assigned display" : { } ' + '}' + x'00'; if (json_validate(json_string)); dsply 'valid'; else; dsply 'invalid'; endif; *inlr = *on; return; /end-free