首页 \ 问答 \ MongoDB ObjectId的JSON问题(JSON issue with MongoDB ObjectId)

MongoDB ObjectId的JSON问题(JSON issue with MongoDB ObjectId)

如您所知,MongoDB文档至少有一个名为_id ObjectId 。 无法将包含ObjectId的文档转换为JSON 。 目前我有两种解决方案将此文档转换为JSON

del doc['_id']

或者用该字段的字符串实例创建一个新文档。

当我知道哪个字段包含ObjectId时它只是起作用。 如果我有多个ObjectId怎么办,我不知道他们是什么?


As you know MongoDB documents has at least one ObjectId named _id. It's not possible to convert a document contains an ObjectId to JSON. currently I have two solutions to convert this document to JSON:

del doc['_id']

or create a new document with a string instance of that field.

What it just works when I know which field contains ObjectId. What to do if I have multiple ObjectId and I don't know what are they?


原文:https://stackoverflow.com/questions/47407537
更新时间:2022-02-21 11:02

最满意答案

显然,GeoExt目前丢弃了服务器信息,破坏了我的问题的整个前提。

这是一个代码片段,可用于告诉GeoExt抓取它。 我没有编写这段代码,但已对其进行了测试,发现它对我有用:

https://github.com/opengeo/gxp/blob/master/src/script/plugins/WMSSource.js#L37


Apparently,GeoExt currently discards the server information, undermining the entire premise of my question.

Here is a code snippet that can be used to tell GeoExt to grab it. I did not write this code, but have tested it, and found it works well for me:

https://github.com/opengeo/gxp/blob/master/src/script/plugins/WMSSource.js#L37

相关问答

更多
  • 除非你提供完整的代码,否则我只能做一些猜测。 你的两层有不同的投影。 我猜您使用epsg:3857进行视图投影,因此使用此范围内的坐标将返回0个epsg:3857 。 首先要尝试的是使用视图投影从地理服务器请求您的图层。 var vectorSource = new ol.source.Vector({ format: new ol.format.GeoJSON(), url: function(extent) { return 'https://geodata.nationaa ...
  • 是的GeoExt 3适用于OpenLayers版本3.但它还没有发布,它正在进行中。 但你可以自由尝试。 Yes GeoExt 3 works with OpenLayers version 3. But it's not released yet, it's work in progress. But you're free to try it out.
  • 似乎问题是网络问题。 是否有来自geoserver和你的应用程序的代理? 您是否尝试过使用geoserver接口来显示WFS文件而不是应用程序? It seems that the problem is the network. Is there a proxy from geoserver and your application? Have you tried using geoserver interface to display your WFS file instead your applicat ...
  • 所以我意识到我从服务器获得了一个Access-Control-Allow-Origin问题...这是通过在服务器上启用CORS来解决的。 一旦我做了方法1工作,但我不得不改变一行: 而不是:$ scope.gridOptions.data = data; 我将其更改为:$ scope.gridOptions.data = data.features; 然后它工作得很好。 希望这有助于某人! :) So I realized I was getting a Access-Control-Allow-Origi ...
  • 问题在于你的jsonp回调 - 你为所有层使用相同的函数名,结果是,正在进行某种形式的数据覆盖。 要修复它,请使用不同的回调名称: // For citiesDefaultParameters format_options : 'callback: getJson_cities', // For wellsDefaultParameters, use format_options : 'callback: getJson_wells', // For parcelsDefaultParameters f ...
  • 好的,所以QGIS Server只能用GML2几何形状提供WFS 1.0.0 ... 上面的示例通过将WFS设置为GML2来工作 var formatWFS = new ol.format.WFS({ 'gmlFormat': new ol.format.GML2 }); okay, so QGIS Server can only serve WFS 1.0.0 with GML2-geometries... the above example works by setting the WFS t ...
  • 我得到了解决方案,首先我安装了Apache,然后修改了httpd.config文件。我刚刚提出 ProxyRequests Off ProxyPreserveHost On Require all granted ProxyPass /geoserver http://localhost:8080/geoserver ProxyPassReverse /geoserver http://localhost:8080/geoserver ProxyPas ...
  • 您可以组合这两个包来完成任务。 首先,使用gdalUtils将您需要的图层转换为本地shapefile。 然后,正常使用rgdal 。 注意:在ogr2ogr调用之后你会看到一条警告信息,但它对我来说转换正常。 此外, ogr2ogr不将overwrite参数设置为TRUE ,则ogr2ogr将不会覆盖本地文件(还有其他参数也可以使用)。 library(gdalUtils) library(rgdal) dsn <- "WFS:http://geomap.reteunitaria.piemonte.it ...
  • 显然,GeoExt目前丢弃了服务器信息,破坏了我的问题的整个前提。 这是一个代码片段,可用于告诉GeoExt抓取它。 我没有编写这段代码,但已对其进行了测试,发现它对我有用: https://github.com/opengeo/gxp/blob/master/src/script/plugins/WMSSource.js#L37 Apparently,GeoExt currently discards the server information, undermining the entire premi ...
  • 我发现了怎么样:) 通过使用: showAt([e.xy.x,e.xy.y]); I found out how :) by using: showAt([e.xy.x,e.xy.y]);

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。