dth34653 2016-04-14 17:24
浏览 228
已采纳

阻止json_encode将空字符串编码为null

Is it possible for the PHP json_encode function do not convert empty string values to null?

UPDATE
I can not replicate this behaviour in clear conditions, and looks like it's already a default for this function.

  • 写回答

2条回答 默认 最新

  • doumiang0597 2016-04-14 17:31
    关注

    This is already the default behavior.

    json_encode(['test' => '']);
    

    generates:

    {"test":""}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?