metafacture / metafacture-fix

Work in progress towards an implementation of the Fix language for Metafacture
Apache License 2.0
6 stars 2 forks source link

Empty element name of subfield is replaced by toplevel element name. #324

Open TobiasNx opened 1 year ago

TobiasNx commented 1 year ago

https://metafacture.org/playground/?flux=inputFile%0A%7C+open-file%0A%7C+as-records%0A%7C+decode-json%0A%7C+fix%28transformationFile%29%0A%7C+encode-json%28prettyPrinting%3D%22true%22%29%0A%7C+print%0A%3B&transformation=nothing%28%29&data=%7B%0A++++%22Hello%22%3A+%22World%22%2C%0A++++%22%22+%3A+%22This+is+an+empty+key%22%2C%0A++++%22some_key%22%3A+%7B%22%22%3A+%22bad+data+here%22%2C+%22ok%22%3A+%22I+am+ok%22%7D%2C%0A++++%22some_array%22%3A+%5B%7B%22%22%3A+%22bad+data+here%22%2C+%22ok%22%3A+%22I+am+ok%22%7D%2C%7B%22ok%22%3A+%22I+am+just+ok%22%7D%5D%0A%0A%7D

{
    "Hello": "World",
    "" : "This is an empty key",
    "some_key": {"": "bad data here", "ok": "I am ok"},
    "some_array": [{"": "bad data here", "ok": "I am ok"},{"ok": "I am just ok"}]

}

With fix nothing()

Results in:

{
  "Hello" : "World",
  "" : "This is an empty key",
  "some_key" : {
    "some_key" : "bad data here",
    "ok" : "I am ok"
  },
  "some_array" : [ {
    "1" : "bad data here",
    "ok" : "I am ok"
  }, {
    "ok" : "I am just ok"
  } ]
}

Should be:

{
  "Hello" : "World",
  "" : "This is an empty key",
  "some_key" : {
    "" : "bad data here",
    "ok" : "I am ok"
  },
  "some_array" : [ {
    "" : "bad data here",
    "ok" : "I am ok"
  }, {
    "ok" : "I am just ok"
  } ]
}
blackwinter commented 1 year ago

See also LibreCat/Catmandu#397 and LibreCat/Catmandu#398.