📔
TerraCraft
  • TerraCraft
  • English
    • Mod Document
      • Mod Dev Official Tutorial
      • Mod API Document
        • Data Types and Enums
        • JSON
        • Entity
        • NPC
  • 简体中文(旧版教程)
    • 模组文档
      • Engine API
        • App
        • AssetBundle
        • AtlasInfo
        • AtlasTextureManager
        • Audio
        • Bytes
        • File
        • GameObject
        • GlobalHook
        • Graphics
        • Hotfix
        • Image
        • ImageInfo
        • IntegratedClient : IntegratedEnv
        • IntegratedEnv
        • JsonUtil
        • Log
        • MathHelper
        • Matrix
        • Path
        • Random
        • Rect
        • Rigidbody
        • TextureLocation
        • TextureManager
        • Transform
        • Vector2
        • Vector3
        • Vector4
      • Game API
        • Attack
        • ArrayList<T>
        • EffectUtils
        • Entity
        • LightingUtils
        • ModNpc
        • ModProjectile
        • Npc : Entity
        • NpcUtils
        • Projectile : Entity
        • ProjectileUtils
        • Reg
        • SoundUtils
        • Utils
      • 模组API文档
        • 数据类型、枚举类型
        • JSON API
        • 引用API
        • 注册信息API
        • 语言API
        • 通用API
        • 物品API
        • 实体API
        • 特效API
        • 抛射物API
        • 状态效果API
        • 附魔API
        • 玩家API
        • NPC API
        • 骨骼模型API
        • 光照API
        • 音效API
        • 方块API
        • 方块实体API
        • 地图API
        • 渲染API
        • 指令API
        • 用户图形界面UI
        • 其他API
      • 模组开发官方教程
        • ExampleMod源代码仓库
        • 1.0 教程对应游戏版本(Indev 1.1)
        • 1.1 开始
        • 1.2 安装Visual Studio Code
        • 1.3 配置模组环境
        • 1.4 认识模组路径
        • 1.5 认识JSON数据表
        • 1.6 第一个物品
        • 1.7 认识地图元素
        • 1.8 第一个图块TODO
        • 1.9 第一个家具TODO
        • 1.10 加入合成表TODO
        • 未完待续……
      • 模组数据表文档
        • 基本JSON类型
        • 模组配置表(tcmod.json)
        • 物品表(contents/items/...)
        • 物品配置表
        • 弹药表(ammos.json)
        • 状态效果表(buffs.json)
        • 音效配置表(sound_config.json)
        • 音效表(sounds.json)
        • 背景表(backgrounds.json)
        • 皮肤表(skins.json)
        • 着色器表(shaders.json)
  • 新版教程
    • 1 基础部分
      • 1.1 安装集成开发环境
      • 1.2 获取TerraCraft源码
      • 1.3 认识Lua
      • 1.4 Mod架构
      • 1.5 游戏主生命周期和主状态机
      • 1.6 Lua实战
      • 1.7 第一个物品
      • 1.8 本地化翻译
      • 1.9 配方系统初探和矿物字典
Powered by GitBook
On this page
  • JsonUtils
  • Json Class
  • Static Function
  • Member Function

Was this helpful?

  1. English
  2. Mod Document
  3. Mod API Document

JSON

JsonUtils

Function

Returns

Description

JsonUtils.SetItemSlot(Json json, string key, ItemSlot itemSlot)

void

为指定JSON写入字符串键和物品格子数据。

JsonUtils.SetItemSlot(Json json, ItemSlot itemSlot)

void

为指定JSON写入物品格子数据。

JsonUtils.GetItemSlot(Json json, string key, ItemSlot itemSlot)

void

从指定JSON根据字符串键读取物品格子数据。

JsonUtils.GetItemSlot(Json json, ItemSlot itemSlot)

void

从指定JSON读取物品格子数据。

JsonUtils.SetItemSlotArray(Json json, string key, ItemSlot itemSlotFirstElement, int length)

void

为指定JSON写入字符串键和物品格子数组数据。itemSlotFirstElement表示物品格子数组的第一个元素,length表示数组长度。

JsonUtils.SetItemSlotArray(Json json, ItemSlot itemSlotFirstElement, int length)

void

为指定JSON写入物品格子数组数据。

JsonUtils.GetItemSlotArray(Json json, string key, ItemSlot itemSlotFirstElement, int length)

void

从指定JSON根据字符串键读取物品格子数组数据。

JsonUtils.GetItemSlotArray(Json json, ItemSlot itemSlotFirstElement, int length)

void

从指定JSON读取物品格子数组数据。

Json Class

The Json class is a serialized object or array that meets the standard JSON syntax specification.

Static Function

Function

Returns

Description

Json:new_local()

Json

Returns a JSON.

Member Function

Object writing function

Function

Returns

Description

Json:SetInt(string key, int value)

void

Write a key-value pair which value is integer.

Json:SetInt(int value)

void

Write an integer value.

Json:SetDouble(string key, double value)

void

Write a key-value pair which value is double.

Json:SetDouble(double value)

void

Write a double value.

Json:SetBoolean(string key, bool value)

void

Write a key-value pair which value is boolean.

Json:SetBoolean(bool value)

void

Write a boolean value.

Json:SetString(string key, string value)

void

Write a key-value pair which value is string.

Json:SetString(string value)

void

Write a string value.

Json:SetJson(string key, Json value)

void

Write a key-value pair which value is JSON.

Json:SetJson(Json value)

void

Write a JSON value.

Json:MoveSetJson(string key, Json value)

void

Write a key-value pair which value is JSON using std::move(value) in C++.

Note: the value is not allowed to be used again after the parameter is passed.

Json:MoveSetJson(Json value)

void

Write a JSON value using std::move(value) in C++.

Note: same above.

Object reading function

Function

Returns

Description

Json:GetInt(string key)

int

Read the integer value. Always returns 0 if does not exist.

Json:GetInt()

int

Read the integer value. Always returns 0 if does not exist.

Json:GetDouble(string key)

double

Read the double value. Always returns 0.0 if does not exist.

Json:GetDouble()

double

Read the double value. Always returns 0.0 if does not exist.

Json:GetBoolean(string key)

bool

Read the boolean value. Always returns false if does not exist.

Json:GetBoolean()

bool

Read the boolean value. Always returns false if does not exist.

Json:GetString(string key)

string

Read the string value. Always returns empty string if does not exist.

Json:GetString()

string

Read the string value. Always returns empty string if does not exist.

Json:HasKey(string key)

bool

Returns whether the current JSON has the specified key.

Array function

函数

返回值

描述

Json:AddJson(string key, Json value)

void

加入一个JSON到当前JSON指定键对应的数组。

Json:MoveAddJson(string key, Json value)

void

加入一个JSON到当前JSON指定键对应的数组。value使用移动构造方式加入,注意传参后value不允许再次使用。

Json:AddJson(Json value)

void

加入一个JSON到当前JSON数组。

Json:MoveAddJson(Json value)

void

加入一个JSON到当前JSON数组。value使用移动构造方式加入,注意传参后value不允许再次使用。

Json:GetList()

ArrayList<Json>

返回当前JSON数组。

Encoding and decoding

Function

Returns

Description

Json:Dump()

string

Returns the current JSON encoded text.

Json:Load(string text)

void

Decode the text to the current JSON.

PreviousData Types and EnumsNextEntity

Last updated 4 years ago

Was this helpful?