💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# JSON Processor(JSON 处理器) 原文链接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.3/json-processor.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/json-processor.html) 译文链接 : [http://www.apache.wiki/pages/viewpage.action?pageId=10027814](http://www.apache.wiki/pages/viewpage.action?pageId=10027814) 贡献者 : [那伊抹微笑](/display/~wangyangting),[ApacheCN](/display/~apachecn),[Apache中文网](/display/~apachechina) 将 **JSON** 字符串转换为一个结构化的 **JSON** 对象。 ## Table 23. Json Options(表 23\. Json 选项) | Name(名称) | Required(必要的) | Default(默认值) | Description(描述) | | --- | --- | --- | --- | | **`field`** | **yes** | **-** | 要解析的 **field**(字段) | | **`target_field`** | **no** | **`field`** | 将已转换的结构化对象插入的 **field**(字段) | | **`add_to_root`** | **no** | **false** | 标记强制将序列化的 **json** 注入到文档的顶层。在该选项使用时,不得设置 **`target_field` **。 | 假设您提供的 **json** 处理器使用的是如下配置 :  ``` { "json" : { "field" : "string_source", "target_field" : "json_target" } } ``` 如果以下文档被处理 :  ``` { "string_source": "{\"foo\": 2000}" } ``` 在经过 json 处理器操作之后,结果如下 :  ``` { "string_source": "{\"foo\": 2000}", "json_target": { "foo": 2000 } } ``` 如果提供以下的配置,省略选项 **target_field** 设置 :  ``` { "json" : { "field" : "source_and_target" } } ``` 然后改 **json** 处理器在这个 **document**(文档)上操作 :  ``` { "source_and_target": "{\"foo\": 2000}" } ``` 结果如下 :  ``` { "source_and_target": { "foo": 2000 } } ``` 这说明,除非在 **processor**(处理器)配置中明确地命名,否则 **`target_field` **与必要的 `**field**` 配置中所提供的字段相同。