go-php-serialize | Golang implementation for PHP 's function serialize | Hashing library
kandi X-RAY | go-php-serialize Summary
kandi X-RAY | go-php-serialize Summary
Golang implementation for PHP’s function serialize() and unserialize().
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of go-php-serialize
go-php-serialize Key Features
go-php-serialize Examples and Code Snippets
Community Discussions
Trending Discussions on go-php-serialize
QUESTION
How I can read conditions unserialised data in golang in map format?
...ANSWER
Answered 2018-Sep-27 at 14:25You're talking about the type of the variable cons
, are you?
If yes, the reason its type is interface{}
is because in PHP, it's possible to serialize a value of any type (from bare integer to a complicated object), and hence any deserialization code must cope with it. Since in Go the so-called "empty interface", interface{}
,
is satisfied by any type at all (including any custom type implemented by a programmer), it's sensbile for a decoder of PHP-serialized data to return a value of type interface{}
.
After making sure decoding succeeded, you need to either type-assert the resulting value to a type you need or to use a type switch to diverge processing based on the concrete type of the value returned by the decoder.
The approach is very well demonstrated by the package you're using in its own test suite.
A snippet from it demonstrating the basic approach
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install go-php-serialize
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page