PHP Classes

File: doc/6_multiple_annotations.md

Recommend this page to a friend!
  Classes of Julian Finkler  >  JSON Object Mapper  >  doc/6_multiple_annotations.md  >  Download  
File: doc/6_multiple_annotations.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: JSON Object Mapper
Create objects of classes mapped from JSON strings
Author: By
Last change:
Date: 4 years ago
Size: 546 bytes
 

Contents

Class file image Download

Multiple Annotations

? Go to index

In some edge-cases a property name in the json can vary:

[
    {"first name": "Foo"},
    {"first*name": "Bar"},
    {"first-name": "Baz"},
    {"first_name": "FooBarBaz"}
]

In this case you can add multiple @JsonField annotations for a property.

class CrappySourceData {
    /
     * @JsonField(name="first name") 
     @JsonField(name="firstname") 
     * @JsonField(name="first-name") 
     * @JsonField(name="first_name") 
     */
    public $firstName;
}
For more information send a message to info at phpclasses dot org.