Comments (7)
@Edwardmark I don't have much experience with cpp, but you are passing the same doc
pointer to the recursive function convertTreeNodeToJSON
, is this a problem?
from yyjson.
@nixzhu Thanks for you reply. I want to convert a tree structure to json, so I have to use the same doc pointer. The problem is about the jsonNode or SubNode in the recursion function. I print the value, it shows when the bottom recursion end, the upper function call cannot get their value, print result is null.
from yyjson.
@Edwardmark I don't have much experience with cpp, but you are passing the same
doc
pointer to the recursive functionconvertTreeNodeToJSON
, is this a problem?
It is not about cpp, I want to verify if the doc owns its subnode memory when calling the recursion function? And what should I do to fix the issue? Thanks .
from yyjson.
@Edwardmark The doc holds memory for all json values, so the recursive call seems good.
There are two string handling issues:
yyjson_mut_str()
doesn't take ownership of the string. If the passed string is modified or freed during use, errors like\u0000
may occur. Consider usingyyjson_mut_strcpy()
instead.- The string returned by
yyjson_mut_val_write()
needs to be freed after use.
If you share the TreeNode
source code, we can better understand and replicate the issue.
from yyjson.
@ibireme Thanks for your reply. It is the problem. I change yyjson_mut_str() to yyjson_mut_strcpy() and it worked.
And for problem2, how to free the string? Could you give me a example? Thanks.
from yyjson.
@ibireme Thanks for your reply. It is the problem. I change yyjson_mut_str() to yyjson_mut_strcpy() and it worked. And for problem2, how to free the string? Could you give me a example? Thanks.
Just call free(json_str)
.
from yyjson.
@ibireme Thanks.
from yyjson.
Related Issues (20)
- mem leak HOT 1
- Static Code Analysis: Identical sub-expressions on both sides of operator "<<" HOT 1
- Shared libraries need to be properly versioned on Linux HOT 1
- Json files are not newline terminated when pretty printing HOT 3
- yyjson_ptr_get_sint() returns false for positive integer HOT 5
- How to change the object key in mutable object? HOT 2
- error: -Wno-implicit-int and -Wno-implicit-function-declaration detected HOT 2
- Support Schema validator HOT 1
- A character make fail the JSON (empty JSON) HOT 1
- Does yyjson have parameters to set decimal places? HOT 4
- Discussion / Feedback request: Incorporating bytearray type HOT 8
- incorrectly formatted bool fields. HOT 3
- I need to merge multiple JSON strings HOT 1
- Is there a method to store the array of primitive types? HOT 4
- Release life cycle HOT 3
- Remove static qualifiers to support wrapping in other languages HOT 5
- Report row and line number when generating errors, instead of an absolute position HOT 10
- Improve error messages HOT 1
- write array obj not correctly HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yyjson.