从JSON字符串转换后,无法在POJO中保留utf-8代码

时间:2014-03-03 16:03:55

标签: java json utf-8

我的JSON返回字符串有类似下面的内容

 ** \u00AE in between some string **

我使用像

这样的jackson解析器进行了解析
returnedPOJO = objectmapper.readvalues(jsonstring,userdefinedclass);

现在,返回的POJO有值,但问题是\ u00AE已更改为某些字符,如y,顶部有2个点。

所以如何解析json到POJO而不修改\ u00AE。

请帮忙。

请参阅下面的json,并找到名称为utf-8的卡片名称

{
    "partner-code":"DINERS",
    "partner":"Diners Club",
    "issuer":"Diners Club",
    "url":"http://dinersclub.com.au/travel_card.htm",
    "mediafile":[

    ],
    "general-terms-and-conditions":"<p style=\"line-height:15.6pt\"><span style=\"font-size: 10pt; font-family: Arial, sans-serif;\">Card products referred to are not Qantas products and not offered or issued by Qantas but by the relevant Card partners. The applicable Card Partner is the credit provider and credit licensee under the National Consumer Credit laws. Points are offered by the relevant Card partner and partner reward program and can only be earned on eligible purchases. Contact the relevant Card Partner for terms and conditions or enquiries.<p></p></span></p>\n\n<p style=\"line-height:15.6pt\"><span style=\"font-size: 10pt; font-family: Arial, sans-serif;\">If you are interested in a Card, make sure you check out all its features on the applicable Card Partner's website as Card features are only summarised here. Card features information is based solely on information supplied by the Card Partner. The information is current as at 13 February 2014 and is subject to change. Qantas has made reasonable efforts to confirm with the applicable Card Partner as to the accuracy of information provided on this site but is not responsible for errors or omissions.<p></p></span></p>\n",
    "card-offerings":[
      {
        "sequence-no":"6",
        **"card-name":"Frequent Flyer Diners Club Card with World MasterCard Card\u00ae",**
        "earning-points":"This charge card lets you earn Qantas Points which are directly credited to your account.",
        "website":"http://dinersclub.com.au/travel_card.htm",
        "contact-phone-number":"1300 360 060",
        "usage-type":"Personal",
        "card-level":"World",
        "card-type-01":"Diners Club",
        "per-dollar-card-type-01":"1.5",
        "earned-area-card-type-01":"1.5 Qantas Points per $1 spend on eligible purchases^ up to $60,000 per annum<br />\r\n<br />\r\n1.25 points per $1 spend on eligible purchases^ over $60,000 per annum",
        "mediafile-card-type-01":{
          "fid":"129266",
          "alt":"",
          "title":"",
          "width":"280",
          "height":"176",
          "uid":"128",
          "filename":"AmexDisco.jpg",
          "uri":"http://qf-partners-media.s3.amazonaws.com/card-banking-partners/AmexDisco_3.jpg",
          "filemime":"image/jpeg",
          "filesize":"28573",
          "status":"1",
          "timestamp":"1392891657",
          "rdf_mapping":[

          ]
        }]}

在将POJO中的转换卡名称值转换为某些值后,是否已使用以下代码读取值并转换为POJO?

JsonFactory jfactory = new JsonFactory();           
JsonParser jParser = jfactory.createJsonParser(jsonStringToconvertAsObjects);


        // advance stream to START_ARRAY first:
        jParser.nextToken();


           while (jParser.nextToken() != JsonToken.END_ARRAY) {

     CardPartner cardPartner = mapper.readValue(jParser, CardPartner.class);

    cardPartnerList.add(cardPartner);
    if(cardPartner!=null)
    {
    for(CardOffer card :cardPartner.getCardOfferings())
    {
                            System.out.println("cardname:"+card.getCardName());
    }
     }
      }

0 个答案:

没有答案