When using toJSON() on an ObjectCollection the names of the properties are always based on the PHP-names. For instance:
For the column type_name the JSON property becomes TypeName, etc.
Is there a way to make Propel use the name of the field/column instead?
If you don't mind using
json_encode, try using the object'stoArray()with arguments:Output:
In other words, use the argument
<ObjectName>Map::TYPE_FIELDNAMEto output an array with column names.The docs are amazing, but they're quite confusing to navigate. I found the following comment from one of the generated models in my project. This is for version
2.0@dev, which I'm using; note that it may differ in your version. (I'd suggest looking at the docs for more formal guidance, but you can take a peek at your models too.)