Questions tagged [jsonresponse]

Provides simple classes for JSON responses that adhere to a standardized structure.

286 questions
34
votes
2 answers

How to use Django's assertJSONEqual to verify response of view returning JsonResponse

I'm using Python 3.4 and Django 1.7. I have a view returning JsonResponse. def add_item_to_collection(request): #(...) return JsonResponse({'status':'success'}) I want to verify if that view returns correct response using unit test: class…
Mariusz Jamro
  • 30,615
  • 24
  • 120
  • 162
25
votes
2 answers

Map object is not JSON serializable

This happens when returning a JSONResponse, which was added in Django 1.7. and is a wrapper around json.dumps. However, in this case it results in an error. I'm sure the data is correct and can be serialized to JSON through Python shell. What is the…
Peter G.
  • 7,816
  • 20
  • 80
  • 154
25
votes
2 answers

Use JSONResponse to serialize a QuerySet in Django 1.7?

I saw that now in Django 1.7 I can use the http.JSONResponse object to send JSON to a client. My View is: #Ajax def get_chat(request): usuario = request.GET.get('usuario_consultor', None) usuario_chat = request.GET.get('usuario_chat',…
Cris_Towi
  • 615
  • 1
  • 13
  • 25
19
votes
2 answers

Getting Request body content using Retrofit 2.0 POST method

I have a requirement to get a request body and to perform some logic operations with Retrofit 2.0 before doing enque operation. But unfortunately I am not able to get the post body content from my service call. At present after searching a lot I…
Chandru
  • 5,954
  • 11
  • 45
  • 85
13
votes
1 answer

Extract statusCode from json response in Laravel

Working in Laravel 5.4 After deleting an image (in my ImageRepository) I send a Json response back to my Controller (where I called the ImageRepository). Now I simply want to check what status code I am getting back to further build on that. return…
nclsvh
  • 2,628
  • 5
  • 30
  • 52
11
votes
1 answer

Django Rest Framework or JsonResponse

I want to make my current more interactive by having ajax that calls for json data, I haven't done anything yet except for research and studying. Here are some things I am not very clear. If JsonResponse and DRF can give the json data i need how is…
Cai HaiBin
  • 173
  • 1
  • 8
10
votes
2 answers

Symfony2 JsonResponse utf8 encoding issues on Debian Stable php-5.4

I'm having issues with JsonResponse on Debian Stable php5 (5.4.39-0+deb7u1) when returning UTF8 chars. I developed an app on Debian Testing php5 (5.6.6+dfsg-2) and the following code worked like a charm: $response = new…
Anton Valqk
  • 747
  • 6
  • 11
6
votes
1 answer

Query result in JSON format (key value pair) on using @Query annotation in Spring Boot, Hibernate

My Controller @GetMapping(value="/getAllDetails") public List getAllDetails() { return MyRepository.getAllDetails(); } My Repository @Repository public interface MyRepository extends CrudRepository { …
Manoj Kumar
  • 139
  • 1
  • 3
  • 12
5
votes
1 answer

Django JsonResponse returning content-type text/html instead of application/json

I've hit a dead end with a django web-project I'm working on and I can't seem to find any answers. I'm trying to test a view as simple as this: def list(request): return JsonResponse( {"foo": "bar"} ) It seems to run all well. If I open the…
Helliaca
  • 183
  • 2
  • 10
5
votes
1 answer

Use JSON object returned from a URL in rails

I am fetching some data from a site using its API-key and some other parameters. I get the data in the form of a JSON object. Now my question is how to use this JSON object in my rails application, maybe doing something like using an instance…
Jimmy Thakkar
  • 549
  • 4
  • 19
4
votes
2 answers

Symfony and Wildurand/Hateoas Bundle - no links on JSON reposnse

I am using FOSRest and Willdurand/Hateoas bundle. I follow examples from https://github.com/willdurand/Hateoas#configuring-links but there is no "links" field on JSON response. /** * Users * * @ORM\Table(name="users") * @ORM\Entity *…
Stevan Tosic
  • 6,561
  • 10
  • 55
  • 110
4
votes
2 answers

Can I return raw json response in angular2

Is it possible for angular2 to return raw json response? Ex. Component getrawJson(){ this.someservice.searchJson() .subscribe( somelist => this.somelist = somelist, error => this.errorMsg = error); } For service …
Erwin
  • 93
  • 1
  • 2
  • 9
4
votes
2 answers

Django view doen't able to return json on ajax success?

I have tried both JsonResponse and HttpResponse(along with json.dumps) but even though ajax is returning to success, returned json can't be parsed by $.parseJSON(returned_json). I am sure that the problem is not with…
Sid
  • 589
  • 6
  • 20
4
votes
2 answers

unit test Spring MissingServletRequestParameterException JSON response

I have POST method in a Spring boot rest controller as follows @RequestMapping(value="/post/action/bookmark", method=RequestMethod.POST) public @ResponseBody Map bookmarkPost( @RequestParam(value="actionType",required=true)…
3
votes
1 answer

How to return separate JSON responses using FastAPI?

I am not sure if this is part of OpenAPI standard. I am trying to develop an API server to replace an existing one, which is not open source and vendor is gone. One particular challenge I am facing is it returns multiple JSON objects without…
amsteel
  • 65
  • 3
1
2 3
19 20