question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I remove the "JSON_" key in front of responses that were formatted with "FOR JSON PATH"

See original GitHub issue

I’m executing a stored procedure which contains a select statement that uses for json path, root('error') and returns info if an error was raised.

I get this: {JSON_F52E2B61-18A1-11d1-B105-00805F49916B: '{"error":[{"ErrorNumber":50…" Instead of this: '{"error":[{"ErrorNumber":50…"

Is there a driver option to remove that exterior ā€œJSON_ā€ wrapper?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
arthurschreibercommented, Dec 1, 2021

šŸ‘‹ @NamedArray

JSON_F52E2B61-18A1-11d1-B105-00805F49916B is the column name that SQL Server uses to send back JSON data, and as you noticed, the data is sent back as a regular string.

If you want to actually use this data in your application, you need to pass the string to JSON.parse as part of your query result handling. Automatic handling for this won’t be added to tedious, because we can’t know what the user’s intentions are, and serializing JSON is a rather expensive operation.

Please let us know if you have any further questions. šŸ™‡ā€ā™‚ļø

1reaction
MichaelSun90commented, Nov 23, 2021

Hi @NamedArray,Thank you for all the details. Just run a query using Sql Server Management Studio with a ā€˜for Json’ key word : ā€œselect colname from table for json pathā€ . In my result set, it also has a ā€˜JSON_’ prefix. Could this be a common behavior for this key word, and not caused by tedious? This is screen shot for my output : image

I also found a page from Microsoft doc that related to this: https://docs.microsoft.com/en-us/sql/relational-databases/json/format-query-results-as-json-with-for-json-sql-server?view=sql-server-ver15 . The examples in this page also includes the ā€˜JSON_’ prefix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to remove json object key and value.? - Stack Overflow
There are several ways to do this, lets see them one by one: delete method: The mostĀ ...
Read more >
What is JSONPath and How to query JSON using ... - Tools QA
JSON , like XML, is a format to provide structure to the data. If you are not familiar with JSON, please go through...
Read more >
Format Query Results as JSON with FOR JSON - SQL Server
In this article. Option 1 - You control output with FOR JSON PATH; Option 2 - SELECT statement controls output with FOR JSON...
Read more >
Using JSONPath effectively in AWS Step Functions
This blog post explains how you can effectively use JSONPath in a Step Functions workflow. It shows how you can separate concerns between...
Read more >
JSON Syntax - W3Schools
JSON - Evaluates to JavaScript Objects. The JSON format is almost identical to JavaScript objects. In JSON, keys must be strings, written with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found