Create a Service with an Input parameter of basetype JSON in Thingworx
Thingworx should recognize the payload as JSON and allow you to traverse it as an object.
I usually start out setting that as String and log it out, so I can make sure I'm receiving what I'm expecting and take the next step from there.
Thanks for replying to my question.
But Actually I created a service and in that I took an input parameter say "v1" of base type "JSON".
Then I just wrote :: logger.warn(v1); as a script, but I got undefined in the logs.
If you see the code snippet which is ::
JSONObject obj2=new JSONObject(); // First JSON Object Containing three attributes
JSONObject obj3=new JSONObject(); // Second JSON Object Containing three attributes
obj.put("partmaster", obj2); // Third JSON Object Containing that two JSON Objects ( Like merging that two object and put in one object)
obj.put("part", obj3); // obj contains "obj2" and "obj3".
I took a input parameter of JSON type at TWX Side in a service then to which JSON obj in the Java code the I/P JSON Variable is referring if I would do that.
I hope you are getting me I want to print this all data which is actually holding by "obj" in java code at ThingWorx side,but unfortunately I am not getting the way.
Can you please more specific about the solution or script,it would be really helpful for me.
Yeah I did that but it is showing "undefined" in the logs.
This is because we are putting wrong i/p or script at TWX side which is not supporting the structure of JSON we defined in the Code.
See this is I am retrieving.
We have to crack that code ::
JSONObj1:Contains some Attribute
JSONObj2:Contains some Attribute
JSONObj3 Contains JSONObj1 & JSONObj2
Now we have to write something which can communicate with this JSONObj3 then retrieve other JSONObj 1& 2.