Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In TSQL converting JSON to XML?

I have a development to execute dinamyc queries stored at column table, all was programmed to manipulating parameters in XML, but there is some other apps that send the parameters in a json, so I would like to know if some one have made something to convert a Json to XML in T-SQL

like image 729
Artemination Avatar asked Nov 15 '25 09:11

Artemination


2 Answers

Just to update this, You can now use OPENJSON to convert to a table and then translate the result to a XML document.

https://learn.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server

SELECT * 
FROM  OPENJSON('{"title": "Sample Konfabulator Widget","name": "main_window" }') as DATA
FOR XML RAW, ELEMENTS
like image 51
Karanko Avatar answered Nov 17 '25 10:11

Karanko


This function works for my tasks: http://sqlsunday.com/2013/05/12/converting-json-data-to-xml-using-a-t-sql-function/

like image 29
Konstantin Taranov Avatar answered Nov 17 '25 10:11

Konstantin Taranov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!