Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Scene files: Invalid YAML?

Discussion in '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. Colin4T2

    Colin4T2

    Joined:
    Mar 20, 2013
    Posts:
    40
    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:
    10
    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:
    15
    You are a dirty, dirty boy.

    Also you get a cookie :D