dimanche 27 mai 2018

Update / Delete .JSON object c# .NET

Hi becouse im newbee with .JSON file manipulating now i need some help from stackoverflow profesionals. Ex.i have a memberlist in .json file and i need to do simple CRUD operations in that file like Delete member with id = 1 or Update member with id = 3 ..

The .json file looks as folow ...

    [{"id":1,"FirstName":"Lolla","LastName":"Lovley","Email":"a@la.com","Gender":"Female","ip_address":"42.7.2.141"},
{"id":2,"FirstName":"Ester","LastName":"Hope","Email":"fg@gh.it","Gender":"Female","ip_address":"23.5.433.09"},
{"id":3,"FirstName":"Erwin","LastName":"Höör","Email":"es2@snes.org","Gender":"Male","ip_address":"22.21.2.9"}]

This .json file is actually acts as service "Web Api" , and that im calling thru AngularJS http request ..

This is a method witch i use to call the Web api to return a .json file

  public HttpResponseMessage Get()
        {

            var json = File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data/members.json"));

            return new HttpResponseMessage()
            {
                Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"),
                StatusCode = HttpStatusCode.OK
            };

        }

And there is no problem , data is coming back ... now as mentioned before i need to write some delete and update , but i dont know how..

Please help!

Regards

/Amra




Aucun commentaire:

Enregistrer un commentaire