Skip to content

Разнообразие стилей в именовании JSON ключей #8

@xboston

Description

@xboston

При выдаче информации о балансе json-ключи имеют разные форматы:

balanceInfoToJson:

resultValue.AddMember("spent", intOrString(balance.spent, isStringValue, allocator), allocator);
resultValue.AddMember("count_received", intOrString(balance.countReceived, isStringValue, allocator), allocator);
resultValue.AddMember("count_spent", intOrString(balance.countSpent, isStringValue, allocator), allocator);
resultValue.AddMember("block_number", intOrString(balance.blockNumber, isStringValue, allocator), allocator);
resultValue.AddMember("currentBlock", intOrString(currentBlock, isStringValue, allocator), allocator);
if (balance.delegated.has_value()) {
resultValue.AddMember("countDelegatedOps", intOrString(balance.delegated->countOp, isStringValue, allocator), allocator);
resultValue.AddMember("delegate", intOrString(balance.delegated->delegate, isStringValue, allocator), allocator);
resultValue.AddMember("undelegate", intOrString(balance.delegated->undelegate, isStringValue, allocator), allocator);
resultValue.AddMember("delegated", intOrString(balance.delegated->delegated, isStringValue, allocator), allocator);
resultValue.AddMember("undelegated", intOrString(balance.delegated->undelegated, isStringValue, allocator), allocator);
resultValue.AddMember("reserved", intOrString(balance.delegated->reserved, isStringValue, allocator), allocator);
}
if (balance.forged.has_value()) {
resultValue.AddMember("countForgedOps", intOrString(balance.forged->countOp, isStringValue, allocator), allocator);

count_received
count_spent
block_number
// но
currentBlock
countDelegatedOps
countForgedOps

resultValue.AddMember("hash", strToJson(bh.hash, allocator), allocator);
resultValue.AddMember("prev_hash", strToJson(bh.prevHash, allocator), allocator);
resultValue.AddMember("tx_hash", strToJson(bh.txsHash, allocator), allocator);
resultValue.AddMember("number", intOrString(bh.blockNumber.value(), isStringValue, allocator), allocator);
resultValue.AddMember("timestamp", intOrString(bh.timestamp, isStringValue, allocator), allocator);
CHECK(bh.countTxs.has_value(), "Count txs not set");
resultValue.AddMember("count_txs", intOrString(bh.countTxs.value(), isStringValue, allocator), allocator);
resultValue.AddMember("sign", strToJson(toHex(bh.signature), allocator), allocator);
resultValue.AddMember("size", bh.blockSize, allocator);
resultValue.AddMember("fileName", strToJson(bh.filePos.fileName, allocator), allocator);

prev_hash
tx_hash
// и
fileName

Аналогично в других местах countBlocks и count_blocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions