Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Scene files: Invalid YAML?

Discussion in 'Formats & External Tools' started by AN_CH, Sep 17, 2015.

  1. AN_CH

    AN_CH

    Joined:
    May 17, 2013
    Posts:
    5
    Hi there,

    as pointed out in http://forum.unity3d.com/threads/smart-merge-not-working.315903/, Unity adds the keyword "stripped" after the object identifier/document boundary marker in the scene files.

    As far as I understand this does not match the YAML specifications and hence is invalid YAML - according to: http://yaml.org/spec/1.1/#document boundary marker/.

    All standard YAML parsers fail to parse scene files which contain a "stripped" keyword near to the document boundary - resulting in a "mapping values are not allowed in this context" exception.

    Test case:
    Enter this in http://www.yamllint.com/ and try to parse it by clicking "Go".

    Also tested with YamlDotNet from https://github.com/aaubry/YamlDotNet, which supports multi-document streams with this patch: https://github.com/aaubry/YamlDotNet/pull/142.

    Any suggestions? Shouldn't you stick to the standard specifications? Or am I just missing something?
     
    Harinezumi likes this.
  2. agorg_louk

    agorg_louk

    Joined:
    Dec 23, 2016
    Posts:
    1
    Bumped into the same problem too.
     
  3. ColinAmuzo

    ColinAmuzo

    Joined:
    Mar 20, 2013
    Posts:
    46
    Same problem here. I'm trying to read Unity's serialized asset data outside of the context of Unity, and the Yaml parser (YamlDotNet) fails when it encounters the "stripped" string.

    Is there a yaml parser which allows this syntax?
     
  4. mattnewport

    mattnewport

    Joined:
    Jan 29, 2016
    Posts:
    15
    Ran into the same problem here. What's the point of using a 'standard' file format if you break it so no standard parser can read it?
     
    Harinezumi likes this.
  5. BWakaBats

    BWakaBats

    Joined:
    Mar 12, 2015
    Posts:
    1
    Bit hacky, but I did this...
    Code (CSharp):
    1.  
    2. string wholeFile = File.ReadAllText(file);
    3. wholeFile = Regex.Replace(wholeFile, "([0-9]+ &[0-9]+) stripped\n", "$1\n");
    4.  
    5. using (var reader = new StringReader(wholeFile))
    6. {
    7.     var yaml = new YamlStream();
    8.     try
    9.     {
    10.         yaml.Load(reader);
    11.     }
    12.     catch { }
    13.     ....
    14.  
     
  6. jchowdown-asla

    jchowdown-asla

    Joined:
    May 10, 2017
    Posts:
    26
    You are a dirty, dirty boy.

    Also you get a cookie :D
     
  7. cgDoofus

    cgDoofus

    Joined:
    Jun 15, 2021
    Posts:
    48
    Apologies for bumping this old thread

    Anyone got around to a better solution other than removing the "stripped" thing? I'm using libyaml event based parsing, already had to modify it to make document tags optional and so far only "stripped" classes are breaking it
     
  8. hadashikick

    hadashikick

    Joined:
    Dec 21, 2016
    Posts:
    1
    Hi. I recently implemented a fast YAML parser in C#.
    This parser supports parsing Unity's `stripped` malformed YAML.
    https://github.com/hadashiA/VYaml
    Give it a try if you like.

    Code (CSharp):
    1. var collection = Yamlserializer.DeserializeMultipleDocuments<dynamic>(yamlBytes)
     
    vsugrob likes this.