Click here to Skip to main content
15,665,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to WCF Rest. I want to read from a JSON object and assign key values to class variables.
Below I want to pass one JSON object inputJSonString to method writeFlatFile. It has three key values, I want those assigned to three variables of LogContact class.
I want those to use inside RestService.svc.

Input Json Object

{"key1":"value1", "key2":"value2", "key3":"value3"};

What I have tried:


namespace RestService
	[WebInvoke( Method="POST", UriTemplate="/writeFlatFile/{inputJSonString}", RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare)]
	bool SaveLog(LogDetail inputJSonString);
public class LogDetail
    public int Log1 { get; set; }

    public string Log2 { get; set; }

    public string Log3 { get; set; }


	bool SaveLog(LogDetail inputJSonString)
		//my program;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900