发布请求并使用Flatbuffers而不是json在Web服务中接收响应?建议链接到这样一个例子

时间:2017-05-29 18:32:54

标签: json serialization flatbuffers

我看过一些帖子,但没有得到这个用例的任何示例,这里有一个链接,我已经提到this。我也读了一些博客,但都是徒劳。

1 个答案:

答案 0 :(得分:1)

它与使用JSON大致相同,只是不使用序列化的JSON字符串,而是发送二进制字节数组(意味着content-type binary/octet-stream的重要性是server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/smuvajse/public; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name ip_of_the_instac; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location / { try_files $uri $uri/ /index.php?$query_string; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # include snippets/fastcgi-php.conf; # # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php7.0-fpm: # fastcgi_pass unix:/run/php/php7.0-fpm.sock; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } ,不是utf-8或其他什么。

这里有关于如何构造和访问字节数组的示例(确保选择JavaScript或您正在使用的任何语言):http://google.github.io/flatbuffers/flatbuffers_guide_tutorial.html