+ 6

How to save data to json file where each data should have a unique id ?

I have a code that sends user entered name to a json file. I want to save that name with a I'd. ex: user entered name -hello I want to save this in json file along with I'd I'd:"0", name:"hello" etc next time I'd must be 1and continues. I hope you are understood. Please help me to make that possible. Please give code of it.

24th Jun 2018, 2:43 AM
Subrahmanya Mayya
Subrahmanya Mayya - avatar
1 Answer
+ 2
A basic can be to retrieve the Json data from the file on every new insert and find out its last saved id and increment that by 1 then use the resulting number as the Id for the row to be inserted next.....
24th Jun 2018, 10:51 PM
Nsamba Abubaker
Nsamba Abubaker - avatar