JsonUtil.php 554 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace Com\Pdd\Pop\Sdk\Common;
  3. /**
  4. * 全局处理字符串
  5. */
  6. class JsonUtil
  7. {
  8. /**
  9. * @param $doc属性字段的注解
  10. * @return 然后数组,$arr[0]是类型, $arr[1]是映射的名称
  11. */
  12. public static function parseDoc($doc)
  13. {
  14. $pattern = '/@JsonProperty\(([\w|\<|\>|\\\\]+),[\s?]\"(\w+)\"\)/i';
  15. preg_match($pattern, $doc, $matches);
  16. if ($matches && count($matches) == 3) {
  17. return array($matches[1], $matches[2]);
  18. } else {
  19. return NULL;
  20. }
  21. }
  22. }