Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于第八章的解答篇 #207

Open
coderhare opened this issue Dec 9, 2021 · 4 comments
Open

关于第八章的解答篇 #207

coderhare opened this issue Dec 9, 2021 · 4 comments

Comments

@coderhare
Copy link

Milo貌似由于工作原因一直没更新,这里放出自己的答案,test passed(620/620),欢迎交流tutorial08解答

@coderhare
Copy link
Author

用C++20重写了一遍。使用了智能指针来管理,std::variant来替代union,实现了将几个模块分离封装,然后其余解析思想都是这几章的内容,cppjson,欢迎交流

@liuxiaomingskm
Copy link

学习学习!

@yanfengneng
Copy link

该代码运行会报错:

test.out: /home/yfn/code/json/C_Json/tutorial08/leptjson.c:546: lept_get_number: Assertion `v != NULL && v->type == LEPT_NUMBER' failed.

@Celin-Yao
Copy link

该代码运行会报错:

test.out: /home/yfn/code/json/C_Json/tutorial08/leptjson.c:546: lept_get_number: Assertion `v != NULL && v->type == LEPT_NUMBER' failed.

这行代码报错原因在于,leptjson.c文件中应为
void lept_shrink_object(lept_value* v) {
assert(v != NULL && v->type == LEPT_OBJECT);
if(v->u.o.capacity > v->u.o.size)
{
v->u.o.capacity = v->u.o.size;
v->u.o.m = (lept_member *)realloc(v->u.o.m, v->u.o.capacity * sizeof(lept_member)); /*原先写的是sizeof(lept_value) */
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants