Android Question Offilen JSON

Status
Not open for further replies.
HI guys i am working on some project that using json, first i try the online json and its perfectly work.

but right now iam developing json that built in flask python, still offline, how can i use my offline json (localhost) json?

please, i need it seriously ?
 

Peter Simpson

Expert
Licensed User
Longtime User
but right now iam developing json that built in flask python, still offline, how can i use my offline json (localhost) json? ?

You can use the following software offline on your development pc or any internal computer to emulate any online server for JSON responses.


Enjoy...
 
Upvote 0
Example JSON:
dim j as HTTPJob
j.initialize("",Me)
j.download("http://127.0.0.1:5000/myapi")

that means i cant use a code like that, isnt it? with localhost?
 
Upvote 0
i have my own api built in flask, when i run my api, it shows like this.
flask.PNG

when i try the api in postman, it works like this.
json.PNG


but when i try from my app (heres my app code)
main.PNG


but it show error like this .
error.PNG


i hope you understand guys, sorry for my bad english:)
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Have you not spotted this???

The example in the linked will give you this JSON output.
Output of the test in the link below:
{
    "Key2": "Value2",
    "Key": "Value"
}
[
    {
        "Record": "1",
        "Key": "Value1"
    },
    {
        "Record": "2",
        "Key": "Value2"
    }
]
[
    {
        "ResponseTime": "\/Date(123)\/",
        "Records": [
            {
                "Record": "1",
                "Key": "Value1"
            },
            {
                "Record": "2",
                "Key": "Value2"
            }
        ]
    }
]


And you can parse the JSON data back with this code
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim Key2 As String = root.Get("Key2")
Dim Key As String = root.Get("Key")
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
The search engine on this absolutely fabulous forum does in fact work you know @Rafi Fahreza, just search for it. There is probably more up to date links and information, but I've got other things that I have to start doing now, like starting to cook the dinner..

 
Upvote 0
127.0.0.1 will not work. This points to the device itself, even if you are running it on the emulator.

Start with a real device and put the PC ip address. You will need to first open the relevant port in Windows firewall.

okayy, i checke my computer address via cmd "ipconfig" and it show 192.168.100.9

so should i change the 127.0.0.1 with that address?
 
Upvote 0
Status
Not open for further replies.
Top