I am trying to populate listview from JSON data but its not working -
the Json
{
"reg": {
"user": [{
"LastEdited": "16 Apr 2014 03:18:25",
"Picture": "\/storage\/sdcard0\/XLEZData\/XLEZ_Input\/Client\/22U2621210__PIN_Ver1.0\/image002.png",
"Email": "adil#adil.com",
"Name": "adil"
}, {
"LastEdited": "16 Apr 2014 03:18:55",
"Picture": "\/storage\/sdcard0\/XLEZData\/XLEZ_Input\/Client\/22U2621210__PIN_Ver1.0\/image002.png",
"Email": "adil",
"Name": ""
}, {
"LastEdited": "24 Apr 2014 10:57:34",
"Picture": "\/storage\/sdcard0\/Pictures\/Screenshots\/Screenshot_2013-07-11-14-33-35.png",
"Email": "test#s3.com",
"Name": "s3 test"
}]
}
}
I have this list in native android like this
How can i make this in jQueryMobile ?
Related
How do I dynamically route JSON in React?
Say the JSON is the code below:
[{ "id": 1,
"fullName": "Jenny Chan",
"address": "3 waterfoot road",
"phoneNumber": "333-962-7516",
"email": "jenny.chan#email.com"
},
{
"id": 2,
"fullName": "Jessica warren",
"address": "4 tall town",
"phoneNumber": "011-211-7516",
"email": "jessica.warren#email.com"
},
{
"id": 3,
"fullName": "Tony Frank",
"address": "11 lesly road",
"phoneNumber": "788-962-7516",
"email": "tony.frank#email.com"
},]
And in my table I have the three emails.
jenny.chan#email.com
jessica.warren#email.com
tony.frank#email.com
When I click on these emails I would like for them to dynamically route to each page.
How do I do this and then pass through the emails as destructured props so I can access the email information please???
Thanks
I have been trying to load a json file in postgres as a single json column.
Table:
create table book(values json);
The file looks like this:
[
{
"isbn": "846896359-3",
"title": "Jungle Book 2, The",
"price": 22.05,
"date": "12/28/2017",
"authors": [
{
"first": "Marlène",
"last": "Ashley",
"age": 38
},
{
"first": "Miléna",
"last": "Finley",
"age": 37
},
{
"first": "Stévina",
"last": "Bullus",
"age": 44
}
],
"publisher": {
"name": "Youspan",
"address": {
"street": "Iowa",
"number": "853",
"city": "München",
"country": "Germany"
},
"phone": "361-191-8111"
}
},
{
"isbn": "558973823-7",
"title": "Star Trek III: The Search for Spock",
"price": 36.58,
"date": "4/19/2017",
"authors": [
{
"first": "Uò",
"last": "Ibel",
"age": 26
},
{
"first": "Mélys",
"last": "Grasner",
"age": 36
},
{
"first": "Mylène",
"last": "Laven",
"age": 40
},
{
"first": "Pò",
"last": "Lapsley",
"age": 37
}
],
"publisher": {
"name": "Chatterbridge",
"address": {
"street": "Dennis",
"number": "1",
"city": "São Tomé",
"country": "Sao Tome and Principe"
},
"phone": "845-226-0017"
}
}
]
Tried the copy command but it throws a 'Token "" is invalid.' error. I have also tried a number of other solutions
So, I finally got it to work.
First I removed new line characters from the file using
tr -d '\n' < yourfile.txt
Then I ran the following script:
create table Bookstemp(values text);
copy Bookstemp from 'BOOKS_DATANew.json';
create table books(valjson json);
Insert into books
select values
from (
select json_array_elements(replace(values,'\','\\')::json) as values
from Bookstemp
) a;
Please bear with me I'm still learning about JSON and programming in general. So I have this JSON file:
{
"root_200888546292191": {
"fields": {
"buyerId": "31392191"
},
"id": "200718546292191",
"tag": "root",
"type": "biz"
},
"shippingInfo_#package#OF04472002179150#WAREHOUSE_ACCEPTED": {
"fields": {
"delivery": {
"createdAt": "Sen 09 Apr - Rab 11 Apr",
"desc": "Standar",
"email": null,
"method": "Standard",
"status": "info"
},
"statusMap": {
"active": "Dalam proses",
"all": ["Dalam proses", "Dalam pengiriman", "Telah diterima"]
},
"trackingList": [{
"info": "Status One",
"updatedAt": "05 Apr 2018 - 11:00"
}, {
"info": "Status Two",
"updatedAt": "05 Apr 2018 - 11:00"
}]
},
"id": "#package#OF04472002179150#WAREHOUSE_ACCEPTED",
"tag": "shippingInfo",
"type": "biz"
},
"shippingInfo_#package#AAAAAAAAAAAAA#NOT_WAREHOUSE_ACCEPTED": {
"fields": {
"delivery": {
"createdAt": "Sen 09 Apr - Rab 11 Apr",
"desc": "Standar",
"email": null,
"method": "Standard",
"status": "info"
},
"statusMap": {
"active": "Dalam proses",
"all": ["Dalam proses", "Dalam pengiriman", "Telah diterima"]
},
"trackingList": [{
"info": "Status Three",
"updatedAt": "05 Apr 2018 - 11:00"
}, {
"info": "Status Four",
"updatedAt": "05 Apr 2018 - 11:00"
}]
},
"id": "#package#AAAAAAAAAAAAA#NOT_WAREHOUSE_ACCEPTED",
"tag": "shippingInfo",
"type": "biz"
},
"login_200718577292191": {
"fields": {
"buyerEmail": "myemail#gmail.com",
"buyerName": "myname"
},
"id": "200718522292191",
"tag": "login",
"type": "biz"
}
}
And I want to extract Info in shippingInfo_ > fields > trackingList So the output that I want is like this:
Status One
Status Two
Status Three
Status Four
The string after shippingInfo_ is always random, how do I extract it with jq?
This is as far as I've got jq '.shippingInfo_*.fields.trackingList.info'
Direct approaches
There are many direct approaches, e.g.:
Using paths
paths as $p
| select( $p|length == 5 and
($p[0] | startswith("shippingInfo_")) and
$p[1:3] == ["fields", "trackingList"] and
$p[4] == "info")
| getpath($p)
Using to_entries
to_entries[]
| select(.key | startswith("shippingInfo_"))
| .value
| .fields.trackingList[]
| .info
Indirect approaches
There are also some indirect approaches that are worth mentioning, e.g.
Using a helper function
def dot(s):
to_entries[] | select(.key|test(s)) | .value ;
dot("^shippingInfo_")
| .fields.trackingList[]
| .info
The last-mentioned filter can be abbreviated to:
dot("^shippingInfo_").fields.trackingList[].info
Relaxed requirements
If it is acceptable to ignore the "^shippingInfo_" requirement, the following may be worth considering as well:
.[].fields.trackingList[]?.info
or even:
.. | objects.fields.trackingList[]?.info
I'm trying to write extract the name value "Acura" from a JSON array response by using the location of the value stored in a variable called "jsonFieldName".
Below is the code that I'm trying to do this with, however, everytime i run the script, SOAPUI returns error: "java.lang.NullPointerException: Cannot get property 'name' on null object error at line: 156"
Can someone kindly advise how to do this?
import groovy.json.JsonSlurper
def response = '''{
"makes": [
{
"id": 200002038,
"name": "Acura",
"niceName": "acura",
"models": [
{
"id": "Acura_ILX",
"name": "ILX",
"niceName": "ilx",
"years": [
{
"id": 200471908,
"year": 2014
}
]
},
{
"id": "Acura_ILX_Hybrid",
"name": "ILX Hybrid",
"niceName": "ilx-hybrid",
"years": [
{
"id": 200493809,
"year": 2014
}
]
},
{
"id": "Acura_MDX",
"name": "MDX",
"niceName": "mdx",
"years": [
{
"id": 200465929,
"year": 2014
}
]
},
{
"id": "Acura_RDX",
"name": "RDX",
"niceName": "rdx",
"years": [
{
"id": 200467168,
"year": 2014
}
]
},
{
"id": "Acura_RLX",
"name": "RLX",
"niceName": "rlx",
"years": [
{
"id": 100539511,
"year": 2014
}
]
},
{
"id": "Acura_TL",
"name": "TL",
"niceName": "tl",
"years": [
{
"id": 200488448,
"year": 2014
}
]
},
{
"id": "Acura_TSX",
"name": "TSX",
"niceName": "tsx",
"years": [
{
"id": 200490517,
"year": 2014
}
]
},
{
"id": "Acura_TSX_Sport_Wagon",
"name": "TSX Sport Wagon",
"niceName": "tsx-sport-wagon",
"years": [
{
"id": 200673755,
"year": 2014
}
]
}
]
},
{
"id": 200001769,
"name": "Aston Martin",
"niceName": "aston-martin",
"models": [
{
"id": "Aston_Martin_DB9",
"name": "DB9",
"niceName": "db9",
"years": [
{
"id": 200473436,
"year": 2014
}
]
},
{
"id": "Aston_Martin_Rapide_S",
"name": "Rapide S",
"niceName": "rapide-s",
"years": [
{
"id": 200460643,
"year": 2014
}
]
},
{
"id": "Aston_Martin_V8_Vantage",
"name": "V8 Vantage",
"niceName": "v8-vantage",
"years": [
{
"id": 200472947,
"year": 2014
}
]
},
{
"id": "Aston_Martin_Vanquish",
"name": "Vanquish",
"niceName": "vanquish",
"years": [
{
"id": 200431313,
"year": 2014
}
]
}
]
}
],
"makesCount": 2
}'''
def jsonFieldName = ('makes[0].name')
def json = new JsonSlurper().parseText (response)
jsonFieldName.split("\\.").each{json = json[it]}
assert json == 'Acura'
Assuming that your JSON is good from the response (check by calling print) Try adding .text to the end of your jsonSlurper() Call
It also looks like you have a space between parseText and (response)
so it should be
def json = new JsonSlurper().parseText(response)
However I would try casting to ArrayList<LazyMap> to ensure you can iterate by
ArrayList<LazyMap> json = new JsonSlurper().parseText(response) as ArrayList<LazyMap>
Then call :
json.get('Acura')
This line of your code doesn't handle the index resolution:
jsonFieldName.split("\\.").each{json = json[it]}
There is no key with the name makes[0]. Instead there is an array of makes and you are interested on the first one. The following hardcoded line retrieves the name attribute:
def result = json.'makes'[0].'name'
As you can see here there is an additional step to resolve the index operator. Of course you can implement this functionality on your own or use JsonPath instead of JsonSlurper.
OK so I managed to get this working by using JsonPath instead of JsonSlurper.
To achieve this I had to import the following:
import com.jayway.jsonpath.JsonPath
def jsonFieldName = "makes[0].name"
def expectedValue = "Acura"
def jsonSuff = JsonPath.read(response, jsonFieldName)
log.info(jsonSuff)
if (jsonSuff.toString() == expectedValue.toString()){
log.info("Actual value"+jsonSuff+"is equal to expected value"+expectedValue)
}
I am using Firebase in order to do a Facebook auth, I would like to know how to display and access to the profile picture from the returned json which looks like this
{
"uid": "facebook:1419891304993631",
"provider": "facebook",
"facebook": {
"id": "1419891304993631",
"accessToken": "CAAJdUVn89vwBAKYZASyfcpTEeSNZApxJEy7xDoCe8M02xZBCJeW6bneWbPJiXYXo0Oe3BVt4hL4xmVkQG5DnQPUs4AeXf67vx2p5kXPvk0vgsB7EPWUhDQzDZAXa1JLdCZBaVhNDtv39dqyH24qwqVzTxKqH8DRPeSPqga5DjZBsAaqmhcaMyPNXZB26NPZA8RZCS8J0zZAmyO67Lq7W5y3der",
"displayName": "Aaron Hillel Swartz",
"email": "retana.marcelo#gmail.com",
"cachedUserProfile": {
"id": "1419891304993631",
"name": "Aaron Hillel Swartz",
"last_name": "Swartz",
"first_name": "Aaron",
"middle_name": "Hillel",
"gender": "male",
"link": "https://www.facebook.com/app_scoped_user_id/1419891304993631/",
"email": "retana.marcelo#gmail.com",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/s100x100/111…77b0ef39e0&oe=55A9B547&__gda__=1436644689_2ba73b2df6e584b46e5a2f8000d571d8"
}
},
"age_range": {
"min": 21
},
"locale": "es_LA",
"timezone": -6
}
},
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2IjowLCJkIjp7InVpZCI6ImZhY2Vib29rOjE0MTk4OTEzMDQ5OTM2MzEiLCJwcm92aWRlciI6ImZhY2Vib29rIn0sImlhdCI6MTQyOTA4NTA4OH0.ec-5bS1-sTSUfeBwDZRwncZxuABrHwnlIQY5eLYxQBQ",
"auth": {
"uid": "facebook:1419891304993631",
"provider": "facebook"
},
"expires": 1429171488
}
example, with this
<div ng-bind="user.uid"></div>
I can display de user uid which is facebook:1419891304993631 in this case, so, with angular, how can I access to the profile picture property ?
Is there a way to use like a kind of ng-src for this?