Comments (6)
I will release a new version around the end of the year.
But the master branch is stable, and you can use it now.
The function to rename key seems to be rarely used, can you describe how you would use it?
from yyjson.
Added: e98bf96
Note that if the object contains the new_key
, there may be duplicate keys after renaming.
e.g. {"a":1,"b":2}
after renaming "a" to "b" -> {"b ":1,"b":2}
.
You can avoid this by calling yyjson_mut_obj_remove_key()
to remove the new_key
before renaming.
from yyjson.
If your key is a constant string, this function is the simplest:
// use iterator to get the key
yyjson_mut_val *key = ...;
yyjson_mut_set_str(key, "new_str");
If you want yyjson to manage memory for that string, use this function:
// use iterator to get the key
yyjson_mut_val *old_key = ...;
yyjson_mut_val *new_key = yyjson_mut_strncpy(doc, str, str_len);
yyjson_mut_set_strn(old_key, yyjson_mut_get_str(new_key), yyjson_mut_get_len(new_key));
from yyjson.
Oh yyjson_mut_set_str
is not in the released lib that's why I missed it. Are you doing an update soon?
May I also suggest a method for easily updating keys?
Something like:
yyjson_mut_key_set_str(doc, root, "oldKey", "newKey")
from yyjson.
The function to rename key seems to be rarely used, can you describe how you would use it?
Maybe I'm a special case. I use it to fix broken json before feeding it into our system.
from yyjson.
Thanks, my testing shows this works great.
from yyjson.
Related Issues (20)
- 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
- Condition for calling read_number_raw HOT 3
- yyjson library can not get value that I try to parse. HOT 1
- Diff two objects to create a patch HOT 2
- New release? HOT 1
- Meson build system support HOT 1
- Define YYJSON_DISABLE_UTILS makes symbol not found HOT 4
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.