Comments (13)
Is there documentation on how to implement your own visitor pattern during implementation or intercept the event emitter such that you can define a style (flow or block) for a particular field in the object graph?
from yamldotnet.
I was able to set the sequence style to flow only on primitive arrays by adding this code to the VisitSequenceStart() method in AnchorAssigningObjectGraphVisitor class. However, there should be a better way to do this, perhaps making it easier to pass in your own visitor when instantiating the serializer class.
if (sequenceType.IsArray && elementType.IsPrimitive)
{
info.Style = Core.Events.SequenceStyle.Flow;
}
from yamldotnet.
The Serializer class is meant to be a simple facade for the various classes that collaborate to the serialization process. However, it is still work in progress and that's the reason why it is not yet possible to alter the visitors that will be used, but this feature is definitely on top of the list. Your requirement of emitting arrays as flow sequences is the kind of usage that I had in mind when I started this refactoring.
from yamldotnet.
Now that version 2.0.0 is out, I think we should work on making the Serializer more extensible. I will keep you comments in mind while working on it. Thanks
from yamldotnet.
Is flow style for sequences implemented in the current version? I was using YamlDotNet to dump objects but since I've got a few relatively large byte arrays it is making the dump next to unreadable (which defeats the purpose of Yaml :-) ) I was expecting something in SerializerOptions but didn't find anything, then stumbled on this issue. Any news?
from yamldotnet.
Is it there yet, or does anyone have some sort of hack/fix? Much appreciated.
from yamldotnet.
Anyone stumbling upon this, I was able to do it with this fork https://github.com/xoofx/SharpYaml
You then apply this attribute on the fields you want to have a different style:
[SharpYaml.Serialization.YamlStyle(YamlStyle.Flow)]
from yamldotnet.
@mathiassiig Is it possible to submit this as a pull request to the main branch? Especially with GitHub Actions YAML using this in places, it would be useful to have this functionality.
from yamldotnet.
This issue appears to be abandoned, I'm going to close it. I believe this is already implemented.
from yamldotnet.
I can't see any information in this issue or linked issues that this is implemented. Is it, and if so, how can it be accomplished?
Also, is there any way to set max line length for flow-style arrays (making them break when the max length has been reached)?
from yamldotnet.
We don’t have a way of doing that in yamldotnet that I’m aware of. We’re very grateful for pull requests if you want to create one.
from yamldotnet.
Thanks. Unfortunately swamped. I found a (hacky?) workaround: In Visit(YamlSequenceNode sequence)
, check the NodeType
of the items of the sequence and check if they are YamlNodeType.Scalar
.
In any case, it seems this issue was closed erroneously then. You may consider opening it, for clarity.
from yamldotnet.
I closed because there was no comment for 3 years.
from yamldotnet.
Related Issues (20)
- Is the IDeserializer thread safe? HOT 2
- Update benchmark file
- 15.1.0 EnsureRoundTrip no longer works without tag mapping and protected default constructors HOT 4
- yamldotnet is missing NuGet package README file
- Json Compatible Serialization does not produce JSON for nodes.
- Including (parts of) another YAML file HOT 12
- Serilizing an object with tags similar to AWS Cloudformation HOT 4
- FSharp deserialization of records with optional record fields HOT 3
- Overriding the name of a type dynamically HOT 2
- ObjectNodeDeserializer: Naming Convention Error on Deserialization HOT 2
- is it possible to style a string in a special way? HOT 3
- Set license expression on nuget package HOT 1
- Improve nuget package readme HOT 2
- Serialization / deserialization is not thread safe HOT 2
- Very large files fail to parse HOT 6
- Using ```YamlStream``` will cause "property not found" in ```IDeserializer.Deserialize()``` HOT 1
- Empty line in comments HOT 1
- Support for FSharp BCL List deserialization
- Aliases do not resolve correctly in Sequences HOT 1
- Better serialization of strings that look like integers (specifically, octals)
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 yamldotnet.