How to simulate JSON responses?

6

I need something that simulates JSON responses for me. Some time ago I had seen a site that did the following:

  • You pass parameters by a URL, eg ?nome=Wesley&idade=21
  • I got the call in the JSON object like this:

     {
         nome:"Wesley",
         idade : 21
     }
    

But I can not find it, what would something similar do?

    
asked by anonymous 14.07.2014 / 19:22

3 answers

7

If you look for a service you pass some parameters and it returns in JSON ? format

I think it's something similar to .

Where this call: http://echo.jsontest.com/key/value/one/two

It has this return:

{
   "one": "two",
   "key": "value"
}

Verify that this is up to you. Although it does not accept QueryString , as requested in the question.

    
14.07.2014 / 19:32
5

I use this site to mock JSON. Not exactly what you asked for, but it might help: link

    
14.07.2014 / 20:11
0

Basically what you need is to serialize your collection of QueryString s.

In C #, you can create a handler with the following content:

public void ProcessRequest(HttpContext context)
{
    string jsonContent = JsonConvert.SerializeObject(context.Request.QueryString);
    context.Response.ContentType = "text/plain";
    context.Response.Write(jsonContent);
}

All content passed to this handler will be returned in JSON format, just like in your example.

    
14.07.2014 / 19:32