json - 如何创建 Avro 架构?

标签 json apache avro

我想知道这个 json 文档的 Avro 模式是什么样的。
推文.json:

{
  "_id": {
    "$oid" : "54d148b471eb130b1e8b4567"
  },
  "nome": "Marco Correia",
  "tweet": "This and a simple tweet",
  "datahora": "Tue Feb 03 22:15:54 +0000 2015"
}
我创建的架构给出了错误。
架构.avsc:
{
  "type" : "record",
  "name" : "twitter_schema",
  "namespace" : "com.miguno.avro",
  "fields" : [
    {
        "name" : "_id", "type": "array","items": "bytes"
    },

    { "name" : "nome","type" : "string","doc" : "Name of the user account on Twitter.com" },
    { "name" : "tweet", "type" : "string","doc" : "The content of the user's Twitter message" },
    { "name" : "datahora", "type" : "string","doc" : "Unix epoch time in seconds"}

    ],
  "doc:" : "A basic schema for storing Twitter messages"
}

最佳答案

以下架构应该有效

{
    "type" : "record",
    "name" : "twitter_schema",
    "namespace" : "com.miguno.avro",
    "fields" : [

        {"name": "_id", "type":
            {   
                "type" : "record", "name" : "Id", "namespace" : "com.miguno.avro",
                "fields" : [
                    { "name" : "oid","type" : "string"}
                ]
            }
        },
        { "name" : "nome","type" : "string","doc" : "Name of the user account on Twitter.com" },
        { "name" : "tweet", "type" : "string","doc" : "The content of the user's Twitter message" },
        { "name" : "datahora", "type" : "string","doc" : "Unix epoch time in seconds"}

  ]
 }

关于json - 如何创建 Avro 架构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28802063/

相关文章:

python - 使用 Python 将 PDF 转换为 HTML

java - 在 java 中使用 Apache Tika 从 pdf 文件中提取文本

java - Apache kafka 与 AVRO,模式 id 在消息中的哪里?

android - 有没有办法禁用通过 proteus 膨胀的 webview 中的缓存

php - 如何解决 mysql_fetch_assoc() 问题

javascript - 无法将 JSON 字符串转换为 javascript 对象

php - Android 使用 php 服务器连接 mysql 数据库

macos - 我无法让 Mercurial 在 Mac OS X Lion 上的 Apache 下运行

hbase - 如何在 HBase 0.96.0+ 中使用 avro?

apache-kafka - 如何在达到特定大小 (128 Mb) 时将 Kafka 消息提交到 HDFS 接收器