Read JSON File From Database in Anuglar

32 Views Asked by At

Is there anyway to read a JSON file from data base. Make some changes and save it back to database in Angular. I had googled it always shows the reading of JSON file from Asset Folder which is not my requirement.

I was expecting to read a file from database store it in a variable and make some changes and store it back to database.

1

There are 1 best solutions below

0
Nick Felker On BEST ANSWER

JSON, JavaScript Object Notation, is the standard representation of object within web apps. What this means is that retrieving your JSON from the database can be saved to a variable in your Angular app. Then you can make your changes and send an update command.

This is demonstrated in a StackBlitz example with explicit functions to do database reads and writes which you will have to update.

Additionally, if the database stores the JSON as a serialized string, you will have to encode/decode using JSON.parse and JSON.stringify on the variable representing the server data.