---
title: "JsonElement::getAsShort() const"
description: 当JsonElement节点为非short数据类型时，通过errno提示调用非法，否则返回short数据类型的该数值。
url: "https://www.hikunpeng.com/document/detail/zh/kunpengaccel/system-lib/dg-ajsonl/kunpengaccel_json_16_0015.html"
---

# JsonElement::getAsShort() const

#### 函数功能

当JsonElement节点为非short数据类型时，通过errno提示调用非法，否则返回short数据类型的该数值。


#### 函数定义

```
short JsonElement::getAsShort() const;
```


#### 返回值

- 成功：返回该节点的short值。
- 失败：返回未初始化的short值。

当该节点数值类型不是short时，会返回未初始化的short数值。
