首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数据库字符串值的json编码问题

数据库字符串值的json编码问题
EN

Stack Overflow用户
提问于 2015-09-01 10:40:35
回答 1查看 109关注 0票数 0

我在php数组中有如下数据库查询结果:

代码语言:javascript
复制
Array
(
    [status] => 1
    [message] => Successfully Login
    [request] => Array
        (
            [firstName] => Jugni
            [lastName] => Patel
            [popup_message] => To login to this portal you have to agree out terms and condition
• L80 – R169 pm x 24 on SMARTCHAT 1GB
• G3 Beat – R259 pm x 24 on SMARTCHAT 1GB
• G3 – R399 pm x 24 on SMARTCHAT 1GB
Top 5 MTN Sales consultants for period 2-8 March 2015, on G3 & G3 Beat sales will WIN R500 each! You have until Monday 9 March 9AM to log your sales for this competition!
        )

)

当我执行上述数组的json_encode时,它在描述中给出了空值。

代码语言:javascript
复制
{"status":"1","message":"Successfully Login","request":{"firstName":"Jugni","lastName":"Patel","popup_message":null}}

更新:

现在,我可以使用utf8_encode方法获得描述的值。但是,当我再次使用json_decode解码该字符串时,它提供了以下输出:

它给出了如下的解码值:

代码语言:javascript
复制
stdClass Object
(
    [status] => 1
    [message] => Successfully Login
    [request] => stdClass Object
        (
            [firstName] => Jugni
            [lastName] => Patel
            [popup_message] => To login to this portal you have to agree out terms and condition
• L80 – R169 pm x 24 on SMARTCHAT 1GB
• G3 Beat – R259 pm x 24 on SMARTCHAT 1GB
• G3 – R399 pm x 24 on SMARTCHAT 1GB
Top 5 MTN Sales consultants for period 2-8 March 2015, on G3 & G3 Beat sales will WIN R500 each! You have until Monday 9 March 9AM to log your sales for this competition!
        )

)

有谁知道在json_encode之后我如何才能得到相同的描述字段值?

EN

回答 1

Stack Overflow用户

发布于 2015-09-01 11:00:02

请确保数组中的字符串是utf8-encoded。编码,编码需要utf8-encoded字符串,并在执行任务时返回false

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32329541

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档