title: Customize Json Response in django rest framework
body: <p>Given below is my serializer class. I have all fields in one model.I would like to change the representation of serializer data in custom format.  Tried to_representation method of  serializer but could not success. </p>
  
  <pre><code>class MyListSerilizer(ModelSerializer):
    class Meta:
      model=MyModel
      fields=['Name','Address_ID','Portal','Address','City','DisplayOrderDateTime','Email','Order_ID','Order_Code','Item_Code','DispatchedOn','Payment_Mode','Shipping_Charge','ShippingMethodCode','ShippingMethodCharges','CashOnDeliveryCharges','CurrencyCode','BillingAddress','GiftWrapCharges','SaleOrderItemCode','Shipping_ref','Cancellable','OnHold','Quantity','Invoice_No''Portal',........]
  </code></pre>
  
  <p>So in my view class defined and output corresponding to them also mentioned over here.</p>
  
  <pre><code>   class MyListAPIView(ListAPIView):
        def list(self,request):
            queryset=MyModel.objects.all()
            serializer=MyListSerilizer(queryset,many=True)
            return Response({'Records':serializer.data})
  </code></pre>
  
  <p>Output :---------->Corresponding to view is</p>
  
  <pre><code>  "Records": [
      {
          "Name": "abc",
          "Address_ID": "6819319",
          "Portal": "amksl",
          "Address": "",
          "City": "absjsls",
          "DisplayOrderDateTime": null,
          "Email": "abcd@gmail.com",
          "Order_ID": "",
          "Order_Code": "",
          "Item_Code": "",
          "DispatchedOn": "",
          "Payment_Mode": ""
       },
        {
           "Name": "abc",
          "Address_ID": "6819319",
          "Portal": "amksl",
          "Address": "",
          "City": "absjsls",
          "DisplayOrderDateTime": null,
          "Email": "abcd@gmail.com",
          "Order_ID": "",
          "Order_Code": "",
          "Item_Code": "",
          "DispatchedOn": "",
          "Payment_Mode": ""
       },
        so on....
  </code></pre>
  
  <p>so my question is how would i achieve this json format. In short how do i customize my view class</p>
  
  <pre><code>     {
        "identifiers":{
                  "email":"abcd@gmai.com",
                  "phone":"123664"
                },
  "activity_type": "purchase",
  "timestamp": "UNIX TIMESTAMP",                
  "products": [{
                  "brandName": "abc",
                  "id": "1",                                  
                  "sku": "abcd",                                
                  "name": "mnis",                           
                  "price": 12.9,
                  "discount": "",
                  "quantity": "",
                  "currency": ""
                   }]
  "cart_info":{
                  "total":"",
                  "revenue":"",
                  "currency":""
              },
  "Order_info":{
                 "total":"2121",
                  .
                  .
                  .
               }
    },
     {
        "identifiers":{
                  "email":"abcd@gmai.com",
                  "phone":"123664"
                },
  "activity_type": "purchase",
  "timestamp": "UNIX TIMESTAMP",                
  "products": [{
                  "brandName": "abc",
                  "id": "1",                                  
                  "sku": "abcd",                                
                  "name": "mnis",                           
                  "price": 12.9,
                  "discount": "",
                  "quantity": "",
                  "currency": ""
                   }]
  "cart_info":{
                  "total":"",
                  "revenue":"",...so on
  </code></pre>