提交 651ed78d 编写于 作者: 杜庆泉's avatar 杜庆泉

json stringify 示例添加

上级 ef9513ad
import { describe, test, expect, Result } from './tests.uts' import { describe, test, expect,expectNumber, Result } from './tests.uts'
...@@ -254,6 +254,15 @@ export function testJSON() : Result { ...@@ -254,6 +254,15 @@ export function testJSON() : Result {
expect(JSON.stringify(obj22)).toEqual('{"data":[{"$m":"test","$p":["type"]}]}') expect(JSON.stringify(obj22)).toEqual('{"data":[{"$m":"test","$p":["type"]}]}')
type A = {
inserted: number
}
const str = '{"inserted": 2}'
const obj33 = JSON.parse<A>(str)!
console.log('-------------------------');
console.log(obj33.inserted);
expectNumber(obj33.inserted).toEqualDouble(2.0)
expect(JSON.stringify(obj33.inserted)).toEqual("2")
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册