Application Integration - JSON to string issue

While developing the integration, I encountered a problem that occurs when trying to write a json string (variable type string) to a database table (target type - text). There is an error that says the value is of object type, and the task schema expects text.

I tried using Json.ToString() in the data mapping task, or create a variable of type string and write data there or both. The only thing that worked for me was to concatenate that string with any other string (other than a whitespace), but the problem is that I need to have a clean json string in the database.

If I concatenate the json string with the <'> symbol on both sides, I get a clean string in the database (without those extra characters), but it only works if the json string has no such character.

Maybe I'm doing something wrong or it's a bug. Please advise how to correctly save json to the database in string format.

Solved Solved
0 3 401
1 ACCEPTED SOLUTION

Solved the problem by using js task mapping

View solution in original post

3 REPLIES 3

Hello @efvcbjdcsdf ,

Welcome to Google Cloud Community!

The problem you're facing is indicating that your value is being interpreted as an object instead of a string.

You can try the following approaches to resolve your issue:

1. If you have already ensured that your JSON string is properly formatted and checked the database schema to ensure the correct data type for the JSON string, you can try escaping any special characters within the string before saving it into the database. You ran refer to this link for more information.

2. Consider using parameterized queries to allow you to pass the JSON string as a parameter. You can learn more about parameterized queries at SQL Shack - Using Parameteriazed Queries to Avoid SQL Injection.

3. If you're still encountering issues, it would be helpful if you provide more specific information about the programming language, database, and code snippets you are using. Alternatively, you can contact Google Cloud Support if the above steps don't help.

Thank you.

Can you pls share a screenshot of your integration and data mapper configurations ?

Solved the problem by using js task mapping