File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 33import base64
44import os
55import logging
6- import json
6+ import orjson
77from django .contrib .staticfiles .storage import staticfiles_storage , HashedFilesMixin
88from django .contrib .staticfiles .finders import find as find_static
99from django .core .serializers .json import DjangoJSONEncoder
@@ -39,10 +39,10 @@ def render_props(self):
3939 return mark_safe ("JSON.parse('{0}')" .format (encoded ))
4040 return '{}'
4141
42- def render_props_b64 (self ):
42+ def render_props_bytes (self ):
4343 if self .props :
44- encoded = base64 . b64encode ( self . json_encoder (self .props ). encode ( "utf-8" )). decode ( 'utf-8' )
45- return mark_safe ("JSON.parse(atob(' {0}' ))" .format (encoded ))
44+ encoded = list ( orjson . dumps (self .props , default = self . json_encoder . __class__ . default ) )
45+ return mark_safe ("JSON.parse(new TextDecoder().decode(new Uint8Array( {0}) ))" .format (encoded ))
4646 return '{}'
4747
4848
Original file line number Diff line number Diff line change 99 install_requires = [
1010 'django>=1.6' ,
1111 'requests>=2,<3' ,
12+ 'orjson==3.10' ,
1213 ],
1314 description = 'Render and bundle React components from a Django application' ,
1415 long_description = 'Documentation at https://github.com/kogan/react-render' ,
You can’t perform that action at this time.
0 commit comments