The data structure parses the data of the Object type in C#. No matter how the front end uses js to parse this data, the precision will be lost.
<!DOCTYPE html>
<html>
<head>
<title>BigNumber.js示例</title>
<script src="https://cdn.jsdelivr.net/npm/bignumber.js/bignumber.min.js"></script>
</head>
<body>
<script>
const jsonStr = '{"total": 8, "items": [{ "userId": "601d1b35-0221-427b-b3f9-b0f8a884a043", "startWay": 0, "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "adc5ef31-a122-4868-a0a8-226712546a86", "creationTime": "2023-07-25T10:00:07+08:00", "eventName": "TaskStarted" }, { "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "5043873d-bdd3-43f8-881b-958cb4759e74", "creationTime": "2023-07-25T10:00:08+08:00", "eventName": "TaskSplitStarted" }, { "subTasks": [{ "subTaskId": "0d54fb77-3705-43ab-85cf-07804af8ebc5", "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "dispatchNo": "4baf8ff6-58e3-4d56-9ddd-8f4e3057c98a", "sequence": 1, "cloudId": "cb656221-d900-43b2-adfd-78610f72e4bb", "clusterId": "b05fdf6a-f6c8-4a72-9083-eb3cf7494f90", "clusterGroup": 95, "status": 4, "resendCount": 0, "createdTime": "2023-07-25T10:00:08+08:00", "sentTime": "2023-07-25T10:00:11+08:00", "startTime": "2023-07-25T10:00:13+08:00", "endTime": "2023-07-25T10:00:48+08:00", "executeSeconds": 35, "isEnded": true }] }, { "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "ad407d3c-4a89-4ecb-a6b9-9b3cdf5bfee9", "creationTime": "2023-07-25T10:00:08+08:00", "eventName": "SubTasksCreated" }, { "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "260ba91f-091d-4b7b-945d-f1d1ea0c411e", "creationTime": "2023-07-25T10:00:08+08:00", "eventName": "TaskSplitFinished" }, { "subTaskId": "0d54fb77-3705-43ab-85cf-07804af8ebc5", "clusterGroup": 95, "sequence": 1, "dispatchNo": "4baf8ff6-58e3-4d56-9ddd-8f4e3057c98a", "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "0d21fcfb-a8c1-478f-ab64-55ba8899c53c", "creationTime": "2023-07-25T10:00:11+08:00", "eventName": "SubTaskSent" }, { "subTaskId": "0d54fb77-3705-43ab-85cf-07804af8ebc5", "sequence": 1, "cloudId": "cb656221-d900-43b2-adfd-78610f72e4bb", "clusterId": "b05fdf6a-f6c8-4a72-9083-eb3cf7494f90", "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "78f7e094-ad76-4b51-93b6-dfbbe496b9e5", "creationTime": "2023-07-25T10:00:13+08:00", "eventName": "SubTaskExecuted" }, { "subTaskId": "0d54fb77-3705-43ab-85cf-07804af8ebc5", "sequence": 1, "cloudId": "cb656221-d900-43b2-adfd-78610f72e4bb", "clusterId": "b05fdf6a-f6c8-4a72-9083-eb3cf7494f90", "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "f15cf411-4882-4cb1-80a7-11df3f0fed38", "creationTime": "2023-07-25T10:00:48+08:00", "eventName": "SubTaskFinished" }, { "taskId": "6b41c1eb-32a4-45a5-9937-47d4bd24471c", "lotNo": 638258760079874090, "id": "c3c7312a-4315-4dd9-801e-8a156f85514c", "creationTime": "2023-07-25T10:00:48+08:00", "eventName": "TaskFinished" }]}';
const jsonObj = JSON.parse(jsonStr, (key, value) => {
if (key === 'lotNo') {
return new BigNumber(value);
}
return value;
});
console.log(jsonObj.items[0].lotNo.toString()); // 输出:638258760079874090
</script>
</body>
</html>