开发者

How can I go about translating Doctrines YAML models into json-schema

开发者 https://www.devze.com 2023-01-06 00:26 出处:网络
Basically I am looking to be able to reuse mode开发者_运维问答l definitions to target both Doctrine models and JSON-Schema.

Basically I am looking to be able to reuse mode开发者_运维问答l definitions to target both Doctrine models and JSON-Schema.

I don't care if it means defining it in a 3rd model language and having the ability to convert that to both yml and json-schema or if it is from json-schema -> yml as long as I have 1 place to update both of them.


Just off the top of my head, you could try parsing the YAML files into PHP arrays and then parsing the arrays into JSON with json_encode() or go the other way and json_decode() the JSON files and then parse the result into YAML format. The included sfYaml classes should be all you need for the YAML parsing/encoding and json_encode/json_decode are included in PHP 5.2 and up.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号