Comments (8)
Sorry, I don't understand your question. Can you be more specific?
from rapidyaml.
Firstly, I am glad to receive your reply. When I was adding data, I found that data can only be added in the form of one key value pair per row, as shown in the following situation:
NodeOne:
- key: a
desc: b
class: c
number: d
- key: e
desc: f
class: g
number: h
- key: i
desc: j
class: k
number: l
If the data volume is large, it will inevitably increase the number of lines in the configuration file. If data can be added as follows, it will inevitably make the entire file structure clearer.
NodeOne:
- {key: a, desc: b, class: c, number: d}
- {key: e, desc: f, class: g, number: h}
- {key: i, desc: j, class: k, number: l}
from rapidyaml.
There are some experimental style flags which you can set on the nodes.
For example, after parsing (or after creating the tree), and before emitting, set the flow style for the specific nodes you want:
for(NodeRef child : tree["NodeOne"].children())
child |= _WIP_STYLE_FLOW_SL;
// now emit. the node will be emitted in single-line flow style
emit(tree);
from rapidyaml.
That's really great. Thank you very much. So how do I save files in this form?
from rapidyaml.
Use the emit overloads that accept FILE*
or the ones that accept streams.
from rapidyaml.
I tried it today, and the content of the original file is
NodeOne:
- {key: a, desc: b, class: c, number: d}
- {key: e, desc: f, class: g, number: h}
- {key: i, desc: j, class: k, number: l}
Obtained after opening and saving
NodeOne: - key: a
desc: b
class: c
number: d - key: e
desc: f
class: g
number: h - key: i
desc: j
class: k
number: l
The code is as follows
::FILE *fp = ::fopen(strFileName.c_str(), "r+");
size_t n_number = ryml::emit_yaml(tree1, fp);
::fclose(fp);
May I ask how I can save the file in its original style. Thank you for taking the time to answer my question.
from rapidyaml.
The parser does not retain the styles when parsing. That feature will eventually be implemented.
But for now, you have to explicitly mark the nodes with the style you want.
from rapidyaml.
Okay, thank you for your reply.
from rapidyaml.
Related Issues (20)
- Issue with empty keys HOT 1
- Support Request: Understanding key() during iteration HOT 5
- [Bug] Keys with ":" cause the value on the next line to be treated as an unquoted scalar HOT 5
- [Bug] Keys with ":" raise parsing error with parsing next blocks HOT 1
- Natvis support is missing some ryml types HOT 5
- Cannot deserialize underscores in numeric literals
- failed to compile on windows with msvc
- cannot compile in g++ 4.8.5 HOT 3
- AddressSanitizer: heap-use-after-free HOT 4
- Redundant c4::is_debugger_attached() checks
- How to serialize subtree as string? HOT 5
- RoNodeMethods should have conditional noexcept HOT 9
- Is scientific notation number supported? HOT 1
- Support for Python 3.12
- rapidyaml assigning out-of-bound id values to new nodes
- How to create a node where key is a dynamic string? HOT 2
- Request: Add more context to error traces HOT 3
- Tree::resolve() leaves some references in place in certain cases HOT 1
- Publish support for more platforms to Conan Central HOT 1
- How to get the correct col for a multiline string
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 rapidyaml.