old_contents: from rest_framework import serializers
  from corehq.form_processor.models import (
      CommCareCaseIndexSQL, CommCareCaseSQL, CaseTransaction,
      XFormInstanceSQL, XFormOperationSQL
  )
  
  
  class XFormOperationSQLSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = XFormOperationSQL
  
  
  class XFormInstanceSQLSerializer(serializers.ModelSerializer):
      history = XFormOperationSQLSerializer(many=True, read_only=True)
      form = serializers.JSONField(source='form_data')
      auth_context = serializers.DictField()
      openrosa_headers = serializers.DictField()
  
      class Meta:
          model = XFormInstanceSQL
          exclude = ('id',)
  
  
  class CommCareCaseIndexSQLSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = CommCareCaseIndexSQL
  
  
  class CaseTransactionActionSerializer(serializers.ModelSerializer):
      xform_id = serializers.CharField(source='form_id')
      date = serializers.CharField(source='server_date')
  
      class Meta:
          model = CaseTransaction
          fields = ('xform_id', 'server_date', 'date', 'sync_log_id')
  
  
  class CommCareCaseSQLSerializer(serializers.ModelSerializer):
      _id = serializers.CharField(source='case_id')
      doc_type = serializers.CharField()
      user_id = serializers.CharField(source='modified_by')
      indices = CommCareCaseIndexSQLSerializer(many=True, read_only=True)
      actions = CaseTransactionActionSerializer(many=True, read_only=True, source='non_revoked_transactions')
  
      class Meta:
          model = CommCareCaseSQL
  
new_contents: from rest_framework import serializers
  from corehq.form_processor.models import (
      CommCareCaseIndexSQL, CommCareCaseSQL, CaseTransaction,
      XFormInstanceSQL, XFormOperationSQL
  )
  
  
  class XFormOperationSQLSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = XFormOperationSQL
  
  
  class XFormInstanceSQLSerializer(serializers.ModelSerializer):
      history = XFormOperationSQLSerializer(many=True, read_only=True)
      form = serializers.JSONField(source='form_data')
      auth_context = serializers.DictField()
      openrosa_headers = serializers.DictField()
  
      class Meta:
          model = XFormInstanceSQL
          exclude = ('id',)
  
  
  class CommCareCaseIndexSQLSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = CommCareCaseIndexSQL
  
  
  class CaseTransactionActionSerializer(serializers.ModelSerializer):
      xform_id = serializers.CharField(source='form_id')
      date = serializers.CharField(source='server_date')
  
      class Meta:
          model = CaseTransaction
          fields = ('xform_id', 'server_date', 'date', 'sync_log_id')
  
  
  class CommCareCaseSQLSerializer(serializers.ModelSerializer):
      _id = serializers.CharField(source='case_id')
      doc_type = serializers.CharField()
      user_id = serializers.CharField(source='modified_by')
      indices = CommCareCaseIndexSQLSerializer(many=True, read_only=True)
      actions = CaseTransactionActionSerializer(many=True, read_only=True, source='non_revoked_transactions')
      case_json = serializers.JSONField()
  
      class Meta:
          model = CommCareCaseSQL
  
subject: make case_json a JSONField