Edit report at https://bugs.php.net/bug.php?id=78332&edit=1

 ID:                 78332
 User updated by:    fi at facelift-bbt dot com
 Reported by:        fi at facelift-bbt dot com
 Summary:            Int in JSON message formatted as string
 Status:             Open
 Type:               Bug
 Package:            PECL
 PHP Version:        7.2.20
 Block user comment: N
 Private report:     N

 New Comment:

Serializing and deserializing in PHP works well, yes.
But after processing the serialized JSON object with the Kafka producer and 
reading the message in a consumer written in Java, the int field has been 
transformed into a string - before deserializing.


Previous Comments:
------------------------------------------------------------------------
[2019-07-24 15:58:12] c...@php.net

This is about https://pecl.php.net/package/rdkafka.

------------------------------------------------------------------------
[2019-07-24 15:24:41] dan...@php.net

Hi - the script you provided does not run, https://3v4l.org/XUMYj . It gives 
the error Fatal error: Uncaught Error: Class 'RdKafka\Producer' not found in 
/in/XUMYj:5

Running json_decode simply as you described it gives: https://3v4l.org/2VPX6 
which appears to give an int.

You might find reading this http://sscce.org/ helpful as a guide on how to 
write a self-contained reproduce case.

------------------------------------------------------------------------
[2019-07-24 14:14:54] fi at facelift-bbt dot com

Test script:
---------------
<?php

$message = '{"id":1639}';

$producer = new RdKafka\Producer();
$topic = $producer->newTopic('myTopic');
$topic->produce(RD_KAFKA_PARTITION_UA, 0, $message);

?>

------------------------------------------------------------------------
[2019-07-24 13:54:32] requi...@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



------------------------------------------------------------------------
[2019-07-24 13:40:40] fi at facelift-bbt dot com

Description:
------------
When producing an encoded JSON object that contains an integer field, the 
consumer always receives the field as string.

Producer: {"id":1639}
Consumer: {"id":"1639"}

Test script:
---------------
$message = '{"id":1639}';

$producer = new RdKafka\Producer();
$topic = $producer->newTopic('myTopic');
$topic->produce(RD_KAFKA_PARTITION_UA, 0, $message);



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=78332&edit=1

-- 
PECL development discussion Mailing List (http://pecl.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to