Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6012025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:20:40+00:00 2026-05-23T02:20:40+00:00

I have created and Android app that has to communicate with my website using

  • 0

I have created and Android app that has to communicate with my website using JSON. JSON (on client, Android side) looks like this:

private static String JSONSend(Context ctx, JSONObject obj, String ObjName, String address) {
    IHttpDispatcher disp = new HttpDispatcher();
    Vector<String> ss = new Vector<String>();
    String link = address;

    String locale = uzmiLocale(ctx);
    if(locale=="")
        return "";
    
    try {
        obj.put("Lokal", locale);
        ss.add(ObjName + obj.toString());
        String ID = disp.getHttpResponse_POST(link, ss);
        return ID;
    } catch (Exception e) {
        return "";
    }
}

Above method is called from here:

public static String sendReq(Context ctx, String txt, String number) {
    JSONObject jsn = new JSONObject();
    try {
        jsn.put("TextPoruke", txt);
        jsn.put("BrTel", number);
        return JSONSend(ctx, jsn, "JSNSend=", "www.mysite.com");
    } catch (JSONException e1) {
        return "";
    }
}

Everything works fine on my Wamp server, but after moving my php code to webserver, nightmare started! Apparently, everything is sent the way it should be, but on serverside this php code is creating problems:

if(isset ($_POST['JSNSend']))
{
$argument = $_POST['JSNSend'];

$json = json_decode($argument,true);
$broj = $json['BrTel'];
$jsnLocale = $json['Lokal'];

it seems that result of "json_decode" is NULL, but $argument equals

{"\TextPoruke\": \"sometext\", \"BrTel\":\"111\"}

So passed JSON string seems ok, but for some reason it can’t be decoded on webserver. Can anyone help me with this? Why is it not working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:20:41+00:00Added an answer on May 23, 2026 at 2:20 am

    Seems like your JSON got escaped prematurely which triggers a bad syntax error.

    If $argument is in the format you state, then the following procedure would work:

    <?php
    
    $s = '{"\TextPoruke\": \"sometext\", \"BrTel\":\"111\"}';
    
    echo 'Without stripslashes:' . PHP_EOL;
    var_dump( json_decode( $s ) );
    
    echo 'With stripslashes:' . PHP_EOL;
    var_dump( json_decode( stripslashes($s) ) );
    
    ?>
    

    Result:

    Without stripslashes:
    NULL
    With stripslashes:
    object(stdClass)#1 (2) {
      ["TextPoruke"]=>
      string(8) "sometext"
      ["BrTel"]=>
      string(3) "111"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a custom button in my Android app that has basically two different
I Have created an android app, which has view flipper and it has 4
I have created a small and simple android app. I tried installing it on
I have created an App Widget for Android 1.5. It uses a TextView to
I have created a UserControl that has a ListView in it. The ListView is
I want to create an app that has pictures Ive taken or created and
I am trying to create a simple 3-D app for android that will have
I'm creating android app that has table layout for the main activity, and that
I have an Android app that uses ActionBar Sherlock. I create a menu that
I have the following app that has a textview and an edittext. When the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.