How to replace the string "\" on json webservice?

Hello

I have problem with this json

"{\"search_result\":[{\"name\":\"Mall Summarecon\",\"category\":\"BusinessEntity\",\"id\":\"1\"},{\"name\":\"Bamboo Dim Sum\",\"category\":\"BusinessEntity\",\"id\":\"2\"},{\"name\":\"Dimsum Ceker\",\"category\":\"Item\",\"id\":\"1\"}]}"

I want to replace the string "\".

the json are already working on my app via .cpp file

I already add json.replace on my qml

function simpleSearch(response){
        indicator.stop()
        model.clear()
        console.log("Response: "+response)
        var json = JSON.parse(response)
        json = json.replace('\\', ' ') // this is how the way i replace
        if (json == "[]")
            notFound.visible = true

        else
            model.append(json.search_result)
    }

but still does not work

is there a different way to replace it?

Thank you

Change your simpleSearchFinished as follows

....simpleSearchFinished()
{
    QNetworkReply *reply = qobject_cast(sender());
    if (!reply->error()){
        QByteArray response = reply->readAll();
        response.replace("\\", "");
        if (response.startsWith("\"")){
            response.remove(0, 1);
        }
        if (response.endsWith("\"")){
            response.remove(response.length()-1, 1);
        }
        emit simpleSearchDone(response);
    }else{
        const int httpCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
        qDebug() << "ErrorCode" << httpCode << endl << \
                "ErrorString" << reply->errorString();
        emit error(httpCode, reply->errorString());
    }
    reply->deleteLater();
    manager->deleteLater();
}

and QML

function simpleSearch(response){
    indicator.stop()
    model.clear()
    var json = JSON.parse(response)
    if (json){ // is VALID/PARSED
        model.append(json.search_result)
    }
}

As I wrote, it is not a good workaround solution. The best is to send VALID JSON string directly from your server. But it works

Tags: BlackBerry Developers

Similar Questions

  • How to create the string of JSON using QVariantMap array?

    Hi all

    How to create sub string of Json using QVariantMap array?

    {
        "Test1": [
            {
                "dataTest1": "0000",
                "dataTest2": 1412,
                "dataTest3": "",
                "dataTest4": "0000",
            }
        ],
        "Test2": {
            "data1": 1412008,
            "data2": "0000",
            "data3": "A",
            "data4": "0000",
        }
    }
    

    Waiting for your answer please reply me as soon as possible.

    JSON array is QVariantList

    JSON object is QVariantMap

    then create a QVariantLsit and insert your QVariantMaps

  • Replace the string value of table

    with cte as)

    Select val '123', 'abwec' double val1

    Union of all the

    Select "456" val, "mowerw" double val1

    Union of all the

    Select val '709', 'wkwere' double val1

    Union of all the

    Select val '078', 'awerwewerwreq' double val1

    )

    Select * from cte;

    -incoming string

    "asdasd123ewrwer@87w8eopiu456werwer@asdwer709@ewrwerewrwqqwezxder078 @..."

    need to replace like 'abwec' 123 and 456 as "mowerw" and 709 as wkwere and 078 as 'awerwewerwreq '.

    How to replace the string value of the string

    I'm going to the table which will have mapping information I need to see the incoming string and replace the appropriate value of the val to val1

    something like

    Of

    "asdasd123456werwer@asdwer709@ewrwerewrwqqwezxder078ewrwer@87w8eopiu @..."

    TO

    "asdasdabwecewrwer@87w8eopiumowerwwerwer@asdwerwkwere@ewrwerewrwqqwezxderawerwewerwreq@..."

    By using the TYPE clause.

    with cte as

    (

    Select val '123', 'abwec' double val1

    Union of all the

    Select "456" val, "mowerw" double val1

    Union of all the

    Select val '709', 'wkwere' double val1

    Union of all the

    Select val '078', 'awerwewerwreq' double val1

    ),

    input_tbl

    as

    (

    Select "asdasd123ewrwer@87w8eopiu456werwer@asdwer709@ewrwerewrwqqwezxder078 @..." input_str

    of the double

    )

    Select max (input_str) Dungeon (first order by desc NWR dense_rank) input_str

    de)

    Select rno, input_str

    de)

    Select rownum NWR

    val

    val1

    input_str

    count (*) over() cnt

    from cte

    Cross

    Join input_tbl

    )

    model

    dimension (NWR)

    measures (val, val1, cnt, CAST (input_str AS VARCHAR2 (4000)) input_str)

    (

    input_str [any] = replace (nvl (input_str [cv () - 1], input_str [cv ()]), val [cv ()], val1 [cv ()])

    )

    )

  • How to divide the string in bb-cascades

    1. I have a table of data as json

      {"RegistrationResult":"Registered Success:Empid:157:TableName:COMPANY156"}
      
    2. Now, how I want to split the show list view in qml and string as the follwing

      Success stories

      EmpID = 157

      TableName = COMPANY156

    3. Please tell the concept of cutting a string and show the result in qml

    I can get the result of the follwing method:

    {"RegistrationResult":["Registered Success","Empid":"157","TableName":"COMPANY156"]}
     
    

    But I do not know how to split the string for a first... Help, please...

    svmrajesh wrote:

    1. ,......"Registered Success:Empid:157:TableName:COMPANY156"}

    Take a look at QString docu

    Just do something like

    myString.split(':')

    and you get a QStringList and this QStringList is directly mapped to a table in QML JavaScript

  • How to replace the first occurrence of a substring

    How to replace the first occurrence of a substring of my original string? everything built in features in PL/SL?
    EX: Original string: "webinweb" I need the output of string as: "xyzinweb" simply replace occuarnce first of 'web' by "xyz".
    SQL> select   regexp_replace('webinweb','web','xyz',1,1) from dual
    /
    REGEXP_R
    --------
    xyzinweb
    
  • How to replace the contents of the settings/passwords backup server / current browser bookmarks?

    Classic scenario: after the bookmark long manual organization Firefox Sync adds trash of its server to my laptop or tablet.

    Where can I find how to replace the content of the backup of the server by settings/passwords / current browser bookmarks? Stupid me, I put a new synchronization and lost this ability.

    It is not recommended to go back to the old version of Sync

    The old version is removed he'll stop being available soon, it takes getting used to using the new version.

    IIRC, it is actually possible to force synchronization of the old working with Fx29 & Fx30 using an old profile or preferences of piracy, but I don't think I should encourage users to try this, but it would be better than using an older version of Firefox which is really bad. In fact using an old outdated version of Firefox is so bad, that it is customary to recommend using a browser on alternative day of someone else instead.

    Firefox ESR is aimed at corporate users, definitely, at the moment, it will use the synchronization of the former. Who will update soon to use synchronization well again, and this time, I guess the synchronization of the former will probably totally frowned upon for example are not available at all.

    It is possible to use the feedback system to leave a short comment on Sync. I would recommend this making, but at least to make very many people of spirit comments that I doubt will have no effect.

  • How to replace the optical drive on the Tecra R940

    Hi all.
    I search everywhere trying to see how to replace the ODD (optical disc drive) of a laptop Toshiba Tecra R940? pt439a-00n003
    its supposed to be easy, but can't get out.

    Anyone know where I can get some info on how to make the?

    Thanks for reading!

    I think that there are just one or two screws holding it on the basic coverage, it then behind the scenes.

  • Satellite Pro L50 - a: how to replace the memory, HARD drive and battery

    I just uploaded 2 new video from Youtube on the L50 - A. Satellite Pro

    The first is a tear down showing how to replace the memory, hard drive and battery (you can also clean the fan if it detects overheating).

    http://www.YouTube.com/watch?v=IG0lW7t92bI

    BTW why they made it so difficult to get just to the battery in this model?

    WARNING - proceed at your own risk and don't forget static precautions!

    Hope they help and if you have any questions let me know.

    + The message was edited: link has been removed ad channel may not +.

    Thanks for these videos. It may be useful to replace the memory, but I think that the owners of the laptop should not open the case. This may void the warranty.
    Be careful about this.

  • How to replace the CD/DVD-Rom on Satellite Pro 2100

    Hello

    My laptop's dvd - rom drive is old and broken, now that I have here an other dvd - rom drive, but I don't know how to remove the old dvd - rom without removing all parts of my laptop. Is there some service manuals how to replace the dvd - rom drive?

    Hello

    I m not 100% sure on the CD/DVD drive replacement on this laptop, but I assume that the procedure is very similar to other portable players.
    For the most part the ODD is secured with the screw at the bottom of the unit.
    You will need to remove this screw to get out and to swap the drive.

    But be careful and don t there if you have no experience!
    Moreover, not all readers are compatible and supported in reason parameters master/slave/c-salt. If you n t know which drives are compatible you should ask the ASP in your country for advice!

  • Qosmio G50 - 10J: how to replace the optical disc drive (ODD)?

    Hello

    the optical drive of my Qosmio G 50 does not work properly, it reads only some movie-DVD, but unfortunately not videogameDVDs at all, so I can't install any games.
    The guarantee is also outdated. So I wanted to ask if it is possible to change the disk myself, if it is then how I had to do and if by the laptop would be in
    risk to get damaged?

    I would be very grateful for each tip and all the help guys can give me!

    Best regards
    a.z.

    Hello

    In various cases the ODD replacement is very delicate.

    If you wish, you can consult this forum category.
    Here you will find some videos how to replace the ODD on the different laptop models:
    http://forums.computers.Toshiba-Europe.com/Forums/Forum.jspa?forumid=115

    This is also a nice Youtube Channel which provides the instructions how to replace the ODD:
    http://www.YouTube.com/user/toshibaeuropesupport

    But the ODD laser lens may be dirty. In my case I could solve similar problem, cleaning the lens of the laser by using a cotton ball and alcohol tip.
    But make sure that this!

  • How to replace the HDD on Satellite 1130?

    How to replace the hard drive in this notebook?

    Hello

    If I remember well HDD is under the optical media drive. Optical media drive is fixed with a screw that you see above the player. Remove the screw and remove the drive from the Bay.

    HARD drive is fixed, I think, 4 screws (probably black). When the screws are removed you can use two fingers to remove the HDD from the connector plug. I hope you now know how to put the new HARD drive.

    Good bye

  • Portege M400: How to replace the pen plastic top?

    How to replace the plastic "pen" at the top of the "pen" (the tool that you use for writing that is specific to this computer).
    I can't find any instructions.

    PS: I want to say that I had to rephrase the question so many times that I get the following

    you mean p * n? He told me that whenever I wanted to write aswell EP *.

    I don't know what exactly you want, you want to replace the tip?
    (if you actuall refers to the Act of writing)

  • How to replace the screen & HDD in Tecra S1

    Could someone help me with 2 queries?
    1. how to replace the screen? I broke my screen 15 "and have a replacement original but would like to know if this is possible without the help of the reseller, etc.
    2. bad drive c. message is 992 KB bad clusters. How to replace or repair the C drive?
    Thank you
    BL

    Hello

    Well, the replacement of HARD disk drive is very easy on the Tecra S1.
    At the bottom of the unit, you will find a cover that protects the HARD drive Bay.
    A screw covers. Remove it.
    Then, it should be possible to remove the HARD drive.

    The replacement of the screen is another matter. It is not easy to remove it. In this case I recommend to contact Toshiba service in your country for details.

  • Re: Satellite A100-692 - how to replace the CD/DVD drive?

    Hello

    the device DVD/combined my A100-692 is damaged and I want to replace it.
    I found no still no guide how to replace the unit.

    Is there something available?

    Thanks in advance!

    Hello!

    AFAIK, you must remove the keyboard first, before you can replace the CD/DVD drive. Remove the screws on the lower side, and then you can push the disc if you have replaced the keyboard.
    It seems to be a bit tricky

    Maybe you should ask a technician for laptop to help. They can replace the CD/DVD drive for you.

    Good bye

  • Equium - how to replace the HARD drive?

    Hello

    I need to replace the hard drive on my Toshiba Equium.
    Can someone tell me the procedure? I changed it once before, and I remember having to press one of the function keys when I turned on the laptop with the new hard drive installed.
    Should I have the recovery disk when the laptop is turned on with the new hard drive installed?

    Thank you very much

    Tim.

    Hey,.

    You should take a look in your user manual. Sometimes you will find a detailed how instruction replace the HARD disk, but it according to your laptop model.

    If you swapped the HARD drive, you need to reinstall Windows. Therefore, you can take the Toshiba Recovery disk that will restore the initial setup in a few minutes with all the drivers and tools. You only have to boot from that drive and that s all! :)

Maybe you are looking for