'How to convert a sql table to JSON or JSON to sql table in nodejs?

Have homework, task is to create currency converter app on nodejs.

I need to take data from the central bank and parse it. I thought, in order not to load the Central Bank server with requests, I need to send and separate data immediately to the database.

At the moment I can receive requests from the server and convert them from XML to JSON.

I'm tried this one.

DECLARE @json NVARCHAR(MAX);
SET @json = N'my-data-from-server';

SELECT * FROM OPENJSON (json, '$.key-that-i-need')
WITH ( id int '$.key.id', ...);

But it get's error while declare @, if i delete first part and only do select it get's error on with.

There is also a question about how I can update the data when updating the data on the Central Bank website.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source