1

I am building an Android, Java-based app that connects to a PHP server and retrieves data from it. As there are only a few different types of entities for now, it doesn't cost that much to encode these entities into JSON in the PHP service's response, decode them when the JSON data is retrieved in Java and recreate entities there. However this means that entities have to be defined once in PHP and once in Java.

I was thinking about JSON-schema as a solution to create a data structure definition once (with the JSON-schema format) and generate entities in both languages from it, unfortunately I didn't find any JSON schema to entity mapper in PHP. Are there any anternatives that allow entities to be generated in both languages ?

edit: I have used PHP Java-bridge in the past but I'm looking for something lighter.

Bruno Pérel
  • 575
  • 6
  • 21

1 Answers1

0

This related answer may help: JSON schema validation with PHP

Apart from using JSON you may consider using XML with XML Schema. It has been around a little longer and PHP provides pretty well documented function for XML data: PHP Manual XML Manipulation

Community
  • 1
  • 1
Marcel P
  • 101
  • 6
  • The project you link to provides _validation_ of a JSON schema, not entity generation, so it can't help me create PHP classes. About XML schema, there doesn't seems to be any generator either. The only one I found is pibx|https://github.com/christophgockel/pibx and it's abandoned – Bruno Pérel Dec 14 '16 at 12:13