将JSON加载到Firestore中 - 数据类型

问题描述:

本机JSON仅支持字符串,数字,布尔值。 Firestore支持其他类型 - 时间戳,地点,日期/时间。你应该如何格式化JSON来加载这些数据类型?将JSON加载到Firestore中 - 数据类型

下面是关于支持的数据类型的一些信息:https://firebase.google.com/docs/firestore/manage-data/data-types

除了一个例子:在protobuf的

var docData = { 
    stringExample: "Hello world!", 
    booleanExample: true, 
    // Note that numbers can be either integers or floating point 
    numberExample: 3.14159265, 
    // JSON representation as RFC 3339 String with timezone Z 
    // e.g. 1815-12-10T00:00:00.000Z 
    dateExample: new Date("December 10, 1815"), 
    arrayExample: [5, true, "hello"], 
    nullExample: null, 
    objectExample: { 
     a: 5, 
     b: { 
      nested: "foo" 
     } 
    }, 
    // JSON object w/ latitude and longitude keys 
    geoPointExample: { 
     latitude: 37.773972 
     longitude: -122.431297 
    }, 
    // Blobs are base64 encoded strings 
    blobExample: "RmlyZXN0b3JlIGlzIGF3ZXNvbWUh" 
}; 

更多信息以JSON可以在这里找到:https://developers.google.com/protocol-buffers/docs/proto3#json

+0

感谢。我并没有真正了解protobuf如何适应这里,但将有助于解决这个问题。 –