Steps to Reproduce
Script Used is
outputs.JSONObj = inputs.obj;
Please see attached screenshots.
None of the formats work as the Object is not recognized as a JSON Object.
JSON field types are interpreted as a string on the ServiceNow platform.
Use JSON.parse to convert a String into a JSON Object. See screenshot of the Parse Script Step:
The subflow might be using an inline script. The variable json_obj is actually interpreted as an object in the engine, so it behaves as you expect it to.
In the subflow, it's not a string but rather returns the object. This object is passed to the action.
Technically the JSON input type is stored as a string on the platform.
The subflow is converting it into a JSON object before passing it to the action, which is why it works with the subflow and not the test action.