title: django-grpc-framework: correct way to serialize/deserialize JSONFields?
body: <p>what is the proper way to handle <em>Django</em> <strong>JSONFields</strong> in the <strong>django-grpc-framework</strong> ?
  How can I check, what kind of data is actually sent (<a href="https://github.com/ktr0731/evans" rel="nofollow noreferrer">Evans</a> throw the same error) =</p>
  <p>When I try to receive a serialized <strong>JSONFiled</strong> with the <a href="https://github.com/fengsp/django-grpc-framework" rel="nofollow noreferrer">django-grpc-framework</a>,</p>
  <p>the following error is thrown in my data_grpc_client.py:</p>
  <blockquote>
  <blockquote>
  <p>python data_grpc_client.py  Traceback (most recent call last):   File &quot;/my_data/data_grpc_client.py&quot;, line 8, in 
  for datum in stub.List(my_data.lara_data_pb2.DataListRequest()):   File &quot;.../python3.9/site-packages/grpc/_channel.py&quot;, line 426, in
  <strong>next</strong>
  return self._next()   File .../lib/python3.9/site-packages/grpc/_channel.py&quot;, line 826, in _next
  raise self grpc._channel._MultiThreadedRendezvous: &lt;_MultiThreadedRendezvous of RPC that terminated with:     status =
  StatusCode.UNKNOWN    details = &quot;Exception iterating responses: Failed
  to parse data_JSON field: expected string or bytes-like object.&quot;
  debug_error_string =
  &quot;{&quot;created&quot;:&quot;@1648155177.535827174&quot;,&quot;description&quot;:&quot;Error received from
  peer
  ipv6:[::1]:50051&quot;,&quot;file&quot;:&quot;src/core/lib/surface/call.cc&quot;,&quot;file_line&quot;:905,&quot;grpc_message&quot;:&quot;Exception
  iterating responses: Failed to parse data_JSON field: expected string
  or bytes-like object.&quot;,&quot;grpc_status&quot;:2}&quot;</p>
  </blockquote>
  </blockquote>
  <p>I would be very happy for any help - thanks a lot in advance !
  Elain</p>
  <p>Here are my python/proto modules - to reproduce the error:</p>
  <p>I have a django (4.0.3) model with a JSON field:</p>
  <pre><code># models.py
  
  class Data(models.Model):
    data_id = models.AutoField(primary_key=True)
    data_JSON = models.JSONField(blank=True, null=True, help_text=&quot;JSON representation of the data&quot;)
  </code></pre>
  <p>My serializer.py looks like this:</p>
  <pre><code>from  my_data.models import Data
  from django_grpc_framework import proto_serializers
  from rest_framework import serializers
  import my_data.my_data_pb2
  
  
  class DataProtoSerializer(proto_serializers.ModelProtoSerializer):
      class Meta:
          model = Data
          proto_class = my_data.my_data_pb2.Data
          fields = ['data_id', 'data_JSON']
  </code></pre>
  <p>The auto generated protofile file (I used the django framework proto generator)  my_data.proto:</p>
  <pre><code>
  syntax = &quot;proto3&quot;;
  
  package my_data;
  
  import &quot;google/protobuf/empty.proto&quot;;
  
  service DataController {
      rpc List(DataListRequest) returns (stream Data) {}
      rpc Create(Data) returns (Data) {}
      rpc Retrieve(DataRetrieveRequest) returns (Data) {}
      rpc Update(Data) returns (Data) {}
      rpc Destroy(Data) returns (google.protobuf.Empty) {}
  }
  
  message Data {
      int32 data_id = 1;
      string data_JSON = 2;
  }
  
  message DataListRequest {
  }
  
  message DataRetrieveRequest {
      int32 data_id = 1;
  }
  </code></pre>
  <p>My service description - services.py :</p>
  <pre><code>
  from my_data.models import Data
  from django_grpc_framework import generics
  from my_data.serializers import DataProtoSerializer
  
  
  class DataService(generics.ModelService):
      &quot;&quot;&quot;
      gRPC service that allows users to be retrieved or updated.
      &quot;&quot;&quot;
      queryset = Data.objects.all().order_by('data_id') 
      serializer_class = DataProtoSerializer
  </code></pre>
  <p>And finally the client: data_grpc_client.py:</p>
  <pre><code>
  import grpc
  import my_data.my_data_pb2
  import my_data.my_data_pb2_grpc
  
  
  with grpc.insecure_channel('localhost:50051') as channel:
      stub = my_data.my_data_pb2_grpc.DataControllerStub(channel)
      for datum in stub.List(my_data.my_data_pb2.DataRequest()):
          print(&quot;datum:&quot;,datum.name, end='')
  </code></pre>