Comments (5)
I have a similar issue. No clue how to resolve it, and it's seriously bothering me during development on my own project.
from sharpyaml.
I've tracked this down to AnchorSerializer.cs. Disabling anchoring and aliases would resolve this issue, yet I cannot find any documentation on how to do this.
from sharpyaml.
YamlSharp.Serializer.Settings.EmitAlias is set to 'true' by default. I thought setting it to 'false' would disable this behavior, but rather, it increased it. Now, every variable was given an anchor tag, due to the fact that aliases (but no anchors) were now disabled. @xoofx, is there really no way to outright disable outputting anchors when Serializer.Serialize(object) is called?
from sharpyaml.
Issue #15 ("How do I get Serialize() to stop putting out anchor and reference labels?") was about this same thing, actually, and the response of setting 'SortKeyForMapping' and 'EmitAlias' both to false before serializing simply does not resolve this (at least not anymore). For now, switching to JSON over YAML seems like a good option due to readability concerns.
from sharpyaml.
You have to use SerializerSettings
and disable aliasing.
using System;
using SharpYaml.Serialization;
namespace SharpYaml.Tests
{
internal class Program
{
public static void Main(string[] args)
{
var settings = new SerializerSettings {EmitAlias = false};
var serializer = new Serializer(settings);
var tester = new Tester() { A = "this is a", B = "this is a"};
var text = serializer.Serialize(tester);
Console.WriteLine(text);
}
public struct Tester
{
public string A { get; set; }
public string B { get; set; }
}
}
}
from sharpyaml.
Related Issues (20)
- The string "null" should be deserialized as a string, not as null
- Question: Plans to support NRT? HOT 2
- Custom naming convention attribute
- Reusing Serializer instance errors HOT 5
- Unable to find package SharpYaml with version (>= 2.1.0)
- Empty node values are resolved to an empty string (`''`) instead of `null`
- Serialization of private properties HOT 2
- Usage samples are lacking information HOT 1
- Custom converter for generic types
- Support for System Immutable collection types HOT 1
- When is the support dimension [2]?
- Preserving comments HOT 2
- Exception was of type 'FileNotFoundException' HOT 1
- Ignore unmapped properties in YAML HOT 4
- No longer can set Alias for property like this: [YamlMember(Alias = "$ref")] HOT 1
- SemanticErrorException when path key exceeds 1023 characters HOT 3
- Quotation marks are need for string like `"1e3"`, otherwise it will be regard as number `1000` HOT 2
- Anchor missing for sibling nested objects HOT 2
- Multiline strings are not emitted in the literal/folded style
- License Confusion HOT 1
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 sharpyaml.