1) Expose global object to drools with methods that can serialize and deserialize JSON. Maybe you could use http://jackson.codehaus.org/.
2) Insert a "wrapper object" into knowledge space that contains a reference to JSON object as text, stream or whatever. 3) Use (1) to deserialize the JSON data in contained in (2). 4) retract (2) 5) insert (3) Obviously the declared object and the JSON object needs to have the same structure. Good luck! // Olle On 12/8/11 6:07 PM, "ihabo01" <ihab...@gmail.com> wrote: >Hello to all, > >I have the following simple rule: > >declare FlatData > param1 : String > param2 : String >end > >rule "Test" > when > a:FlatData(param1=="something") > then > a.setParam2("hi"); >end > > > >And I have the following code to load the rule: > >KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); >kBuilder.add(ResourceFactory.newFileResource("myRule.drl"),ResourceType.DR >L); >KnowledgeBaseConfiguration kBaseConfig = KnowledgeBaseFactory >.newKnowledgeBaseConfiguration(); >KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(kBaseConfig); >kBase.addKnowledgePackages(kBuilder.getKnowledgePackages()); >StatefulKnowledgeSession session = kBase.newStatefulKnowledgeSession(); >session.fireAllRules(); > >And I have also the following object (in Json) that I would like to insert >as a fact just before firing the rules: >{"object":{" FlatData ":{"param1":"value1","param2":²value2²}}}} > >How can I achieve that? > >Many thanks in advance for your help > >Ihab > > >-- >View this message in context: >http://drools.46999.n3.nabble.com/Inserting-Facts-from-Json-Format-tp35708 >10p3570810.html >Sent from the Drools: User forum mailing list archive at Nabble.com. > >_______________________________________________ >rules-users mailing list >rules-users@lists.jboss.org >https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users