php-serialize icon indicating copy to clipboard operation
php-serialize copied to clipboard

How to serialize a object class with private and protected keys ?

Open nicolasopt opened this issue 4 years ago • 2 comments

At first, thanks for your helpful library. In some case I need serialize a js object with private and protected keys to PHP private, protected keys.

Any idea to help me ?

nicolasopt avatar Jul 14 '21 09:07 nicolasopt

Hi @nicolasopt ! Thank you for reaching out. Javascript does not have protected keys, it does have private keys but I don't think we can access them outside the object to serialize them.

This may require us to make a pretty weird API. What's your use-case? Is it possible for you to use another way?

steelbrain avatar Jul 14 '21 10:07 steelbrain

Thank you @steelbrain , My use-case:

  • I want to serialize asgardPHP user object from nestjs API
  • Then that serialize will be used in PHP API from asgard token. Seems I must to find other solution.

nicolasopt avatar Jul 15 '21 01:07 nicolasopt