Json_encode丢失数据 [英] Json_encode missing data

查看:79
本文介绍了Json_encode丢失数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下结构,并且您可以看到json中未返回方法"数据.为什么? 这是一个UML建模程序.

I have the following structure, and as you can see the "methods" data is not returned in the json.Why? This is a UML modeling program.

object(UClass)[1]
  public 'classname' => string 'Class_Temp_1311967657' (length=21)
  public 'classtype' => string 'public' (length=6)
  public 'methods' => 
    array
      0 => 
        object(UFunction)[2]
          private 'name' => string 'Bill' (length=4)
          private 'type' => null
          private 'attributes' => null
          private 'returntype' => null
      1 => 
        object(UFunction)[3]
          private 'name' => string 'Function_Temp_1311967657' (length=24)
          private 'type' => null
          private 'attributes' => null
          private 'returntype' => null
  public 'attributes' => 
    array
      'person' => 
        array
          'type' => string 'string' (length=6)
          'visability' => string 'public' (length=6)
      'id' => 
        array
          'type' => string 'int' (length=3)
          'visability' => string 'public' (length=6)
  private 'interfacesUsed' => 
    array
      empty

而json看起来像这样

And the json looks like this

{"classname":"Class_Temp_1311967657","classtype":"public","methods":[{},{}],"attributes":{"person":{"type":"string","visability":"public"},"id":{"type":"int","visability":"public"}}}

推荐答案

因为私有成员没有被json_encode序列化.

Because private members aren't serialized by json_encode.

这篇关于Json_encode丢失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆