On 01.09.2014 17:06, Jeroen De Dauw wrote:
Hey,

We will hopefully soon switch to our new implementation of the
serialization code. I had a quick look and it seems to have the same
issue though. I filed a ticket for that here:
https://github.com/wmde/WikibaseDataModelSerialization/issues/77

Thanks.


    This would be the right way to do this, but the problem is that in
    php, an empty
    map is indistinguishable from an empty list. So how do we tell the
    json encoder
    when to use what?


Cast the array to object.

Ok, we are trying to work around this somehow for now, but it's quite tricky to do this in a typed programming language where maps and arrays are completely different things. There are some great libraries that can parse fixed format JSON into fixed class objects, which gives you very clean code, but it only works well if the types of values are known ot some extent. If this is not given, you start coding manual parse methods again to add special cases. Since maps occur everywhere in the JSON, and all of them could sometimes be empty, this affects a lot of code.

Markus



_______________________________________________
Wikidata-tech mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-tech

Reply via email to