Is there an elegant way to scrape data from URLs such as below directly into a dataframe?:
https://israeldrugs.health.gov.il/#!/medDetails/145%2020%2032014%2000
Try:
import requests
import pandas as pd
url = "https://israeldrugs.health.gov.il/#!/medDetails/145 20 32014 00"
api_url = (
"https://israeldrugs.health.gov.il/GovServiceList/IDRServer/GetSpecificDrug"
)
drug_id = url.split("/")[-1]
data = requests.post(api_url, json={"dragRegNum": drug_id}).json()
df = pd.json_normalize(data)
print(df)
Prints:
dragRegNum dragHebName bitulDate isCytotoxic isVeterinary applicationType brochure brochureUpdate isPrescription iscanceled images dragEnName usageFormHeb usageFormEng dosageForm dosageFormEng dragIndication maxPrice health activeMetirals regOwnerName regManufactureName regDate regExpDate applicationDate custom manufacturers limitations dateOfInclusion indicationIncludedInTheBasket classEffect remarks packingLimitation registeredIndicationsAtTimeOfInclusion frameworkOfInclusion useInClalit salList atc packages videos
0 145 20 32014 00 אדויל פורטה 400 01/01/1900 False False תכשיר גנרי [{'lng': None, 'url': 'Rishum_17_463219520.pdf', 'updateDate': 1607238596000.0, 'type': 'החמרה לעלון', 'display': 'החמרה לעלון', 'updateDateFormat': '06.12.2020', 'creationDateFormat': '25.11.2020'}, {'lng': None, 'url': 'Rishum_20_510626721.pdf', 'updateDate': 1624563325000.0, 'type': 'החמרה לעלון', 'display': 'החמרה לעלון', 'updateDateFormat': '24.06.2021', 'creationDateFormat': '14.06.2021'}, {'lng': 'אנגלית', 'url': 'Rishum_19_248052021.pdf', 'updateDate': 1613923027000.0, 'type': 'עלון לצרכן', 'display': 'עלון לצרכן אנגלית', 'updateDateFormat': '21.02.2021', 'creationDateFormat': '13.01.2021'}, {'lng': 'עברית', 'url': 'Rishum_20_510625821.pdf', 'updateDate': 1624563286000.0, 'type': 'עלון לצרכן', 'display': 'עלון לצרכן עברית', 'updateDateFormat': '24.06.2021', 'creationDateFormat': '14.06.2021'}, {'lng': 'ערבית', 'url': 'Rishum_19_248050821.pdf', 'updateDate': 1613922982000.0, 'type': 'עלון לצרכן', 'display': 'עלון לצרכן ערבית', 'updateDateFormat': '21.02.2021', 'creationDateFormat': '13.01.2021'}, {'lng': None, 'url': 'Rishum_20_510583121.pdf', 'updateDate': 1624560223000.0, 'type': 'עלון לרופא', 'display': 'עלון לרופא', 'updateDateFormat': '24.06.2021', 'creationDateFormat': '14.06.2021'}] None False False [{'url': 'Rishum_1_88158316.jpg', 'updateDate': 1469069874000.0}] ADVIL FORTE 400 פומי PER OS קפסולות ממולאות נוזל CAPSULES LIQUID FILLED Relief of mild to moderate pain such as headache, treatment of pain associated with migraine toothache, menstrual pain, backache, muscular pain, anti-inflammatory for rheumatic disease, reduction of fever. 49.2 False [{'ingredientsDesc': 'IBUPROFEN', 'dosage': '400 MG '}] GSK CONSUMER HEALTHCARE, ISRAEL LTD PFIZER CONSUMER MANUFACTURING ITALY S.R.L 1.454198e+12 1.769818e+12 1.233619e+12 [{'manufactureName': 'CATALENT ARGENTINA SAIC', 'manufactureSite': 'AVENIDA BERNABE MARQUEZ 691 B1657CSA - VILLA LOMA HERMOSA, BUENOS AIRES, ARGENTINA', 'manufactureComments': 'bulk '}, {'manufactureName': 'PFIZER CONSUMER MANUFACTURING ITALY S.R.L.', 'manufactureSite': 'VIA NETTUNENSE 90, APRILILA, ITALY', 'manufactureComments': 'release , testing , labelling , packaging '}] None None None None None None None None None [] [{'atc4Code': 'M02AA', 'atc4Name': 'ANTIINFLAMMATORY PREPARATIONS, NON STEROID FOR TOPICAL USE', 'atc5Code': 'M02AA13', 'atc5Name': 'IBUPROFEN'}] [{'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '96 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '100 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '4 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '6 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '8 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '10 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '12 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '16 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '2.46', 'packageMaxPrice': '49.2', 'quantity': '20 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': '7290012368332'}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '24 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '30 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '32 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '36 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '48 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '50 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}, {'isPrescription': True, 'packageUpdate': 0.0, 'packageDesc': 'BLISTER PVC/PE/PVDC/AL', 'packMaterialDesc': 'PVC/PE/PVDC/AL', 'unitPrice': '0', 'packageMaxPrice': '0', 'quantity': '60 CAPSULES', 'shelfLife': '36', 'unit': 'חדשים', 'barcode': ''}] []
Related
This is my first time posting here, so please let me know if you need more info. I am using stitch and snowflake to query my Shopify data.
I am trying to extract the price, sku, and product_id in LINE_ITEM from a nested array 3 levels down. ORDERS table -> REFUNDS -> REFUND_LINE_ITEMS -> LINE_ITEM. I am successful in extracting data from the first level of the nested array REFUNDS but not REFUND_LINE_ITEM, let alone LINE_ITEM. I would appreciate any help!
select *,
l.value::variant as "line_item"
from (
select o.id as order_id,
r.value:id::string as id,
e.value::variant as "refund_line_items"
from ORDERS o
, lateral flatten(input => refunds) r
, lateral flatten(input => r.value:refund_line_items) e
where financial_status = 'refunded') o
, lateral flatten(input => refund_line_items) r
, lateral flatten(input => r.value:line_item) l;
Here is an example of ORDERS table data.
{
"created_at": "2022-10-20T16:20:15Z",
"id": 69130400,
"order_adjustments": [],
"refund_line_items": [{
"id": 223792431,
"line_item": {
"discount_allocations": [{
"amount": 1.5,
"amount_set": {
"presentment_money": {
"amount": "1.50",
"currency_code": "USD"
},
"shop_money": {
"amount": "1.50",
"currency_code": "USD"
}
},
"discount_application_index": 0
}],
"fulfillable_quantity": 0,
"fulfillment_service": "manual",
"fulfillment_status": "fulfilled",
"id": 60942933,
"name": "widget a",
"pre_tax_price": 13.5,
"pre_tax_price_set": {
"presentment_money": {
"amount": "13.50",
"currency_code": "USD"
},
"shop_money": {
"amount": "13.50",
"currency_code": "USD"
}
},
"price": 15,
"price_set": {
"presentment_money": {
"amount": "15.00",
"currency_code": "USD"
},
"shop_money": {
"amount": "15.00",
"currency_code": "USD"
}
},
"product_exists": false,
"product_id": "122345",
"quantity": 1,
"sku": "118882",
"tax_lines": [{
"price": 0.81,
"price_set": {
"presentment_money": {
"amount": "0.81",
"currency_code": "USD"
},
"shop_money": {
"amount": "0.81",
"currency_code": "USD"
}
},
"rate": 0.06,
"title": "CA STATE TAX"
},
{
"price": 0.07,
"price_set": {
"presentment_money": {
"amount": "0.07",
"currency_code": "USD"
},
"shop_money": {
"amount": "0.07",
"currency_code": "USD"
}
},
"rate": 0.005,
"title": "CA SPECIAL TAX"
},
{
"price": 0.03,
"price_set": {
"presentment_money": {
"amount": "0.03",
"currency_code": "USD"
},
"shop_money": {
"amount": "0.03",
"currency_code": "USD"
}
},
"rate": 0.0025,
"title": "CA COUNTY TAX"
},
{
"price": 0.14,
"price_set": {
"presentment_money": {
"amount": "0.14",
"currency_code": "USD"
},
"shop_money": {
"amount": "0.14",
"currency_code": "USD"
}
},
"rate": 0.01,
"title": "CA SPECIAL TAX"
}
],
"taxable": true,
"title": "widget A",
"total_discount": 0,
"total_discount_set": {
"presentment_money": {
"amount": "0.00",
"currency_code": "USD"
},
"shop_money": {
"amount": "0.00",
"currency_code": "USD"
}
},
"variant_id": null,
"variant_inventory_management": null,
"variant_title": "",
"vendor": "Company XXX"
},
"line_item_id": 60942933,
"location_id": null,
"quantity": 1,
"restock_type": "no_restock",
"subtotal": 13.5,
"total_tax": 1.05
}],
"restock": false,
"user_id": 3947371
}
One thing that helps parse multi-level JSON... Start with a select * on the flattened array. That exposes a number of columns that Snowflake uses internally when parsing the JSON that you can read and break down.
create temp table foo(v variant);
insert into foo select parse_json('<your json>');
select VALUE:line_item.price::double as PRICE
,VALUE:line_item.sku::string as SKU
,VALUE:line_item.product_id::string as PRODUCT_ID
from foo, lateral flatten (v:refund_line_items);
You can use RECURSIVE => TRUE flag for FLATTEN() function to expand all the nested levels.
select * from ORDERS
, lateral flatten(input => v, RECURSIVE => TRUE);
The resulted table would flatten all the levels and contain additional fields KEY, PATH, VALUE and few others that you can filter on and get access to the data on the required level.
Good day/evening.
I'm trying to retrieve some data from the firebase real-time database, and there's a error when I used the user UID as a child to fetch the data.
Here's the code for it
void initState() {
DatabaseReference ref = FirebaseDatabase.instance.reference();
String userId = (FirebaseAuth.instance.currentUser).uid;
ref.child('User').child(userId).once().then((DataSnapshot snap ){
var keys = snap.value.keys;
var data = snap.value;
allData.clear();
for(var key in keys){
myData d = new myData(
data[key]['Full_Name'],
data[key]['Email'],
data[key]['Phone_Number'],
data[key]['Address']
);
allData.add(d);
}
setState(() {
print('Length:${allData.length}');
});
});
}
For the list
Container(
height: data.size.height,
child: allData.length==0
? SpinKitFadingCircle(
color: Colors.white,
size: 150.0
)
:new ListView.builder(
itemBuilder: (_,index){
return Profile_UI(context,allData[index].Full_Name,allData[index].Email,allData[index].Phone_Number,allData[index].Address);
},
itemCount: allData.length,
),
),
and this is all of the codes
class Profile extends StatefulWidget {
#override
_ProfileState createState() => _ProfileState();
}
class _ProfileState extends State<Profile> {
final AuthenticationService _auth = AuthenticationService();
final FirebaseAuth auth = FirebaseAuth.instance;
User user;
List<myData> allData = [];
#override
// ignore: must_call_super
void initState() {
DatabaseReference ref = FirebaseDatabase.instance.reference();
String userId = (FirebaseAuth.instance.currentUser).uid;
ref.child('User').child(userId).once().then((DataSnapshot snap ){
var keys = snap.value.keys;
var data = snap.value;
allData.clear();
for(var key in keys){
myData d = new myData(
data[key]['Full_Name'],
data[key]['Email'],
data[key]['Phone_Number'],
data[key]['Address']
);
allData.add(d);
}
setState(() {
print('Length:${allData.length}');
});
});
}
#override
Widget build(BuildContext context) {
final data = MediaQuery.of(context);
return Scaffold(
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Stack(
children: <Widget>[
Container(
height: 600.0,
width: data.size.width,
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.cyan[700],
Color(0xFF61A4F1),
Color(0xFF478DE0),
Color(0xFF398AE5),
],
stops: [0.1, 0.4, 0.7, 0.9],
),
),
),
Container(
height: data.size.height,
child: allData.length==0
? SpinKitFadingCircle(
color: Colors.white,
size: 150.0
)
:new ListView.builder(
itemBuilder: (_,index){
return Profile_UI(context,allData[index].Full_Name,allData[index].Email,allData[index].Phone_Number,allData[index].Address);
},
itemCount: allData.length,
),
),
],
),
),
),
);
}
}
class _EditProfilePage extends StatefulWidget {
#override
__EditProfilePageState createState() => __EditProfilePageState();
}
class __EditProfilePageState extends State<_EditProfilePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
elevation: 1,
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: Colors.blueAccent,
),
onPressed: (){Navigator.of(context).pop(MaterialPageRoute(builder: (context)=>MenuTry()));},
),
),
body: Container(
padding: EdgeInsets.only(left: 16,top: 25,right: 16),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF73AEF5),
Colors.blue.shade300,
Colors.blue.shade300,
Colors.blue.shade200,
],
stops: [0.1, 0.4, 0.7, 0.9],
),
),
child: GestureDetector(
onTap:() {FocusScope.of(context).unfocus();
},
child: ListView(
children: [
Text('Edit Profile', style: TextStyle(
fontSize: 25, fontWeight: FontWeight.w500,
),
),
SizedBox(
height: 15,
),
Center(
child: Stack(
children: [
Container(
width: 130,
height: 130,
decoration: BoxDecoration(
border: Border.all(
width: 4,
color: Theme.of(context).scaffoldBackgroundColor,
),
boxShadow: [
BoxShadow(
spreadRadius: 2, blurRadius: 10,
color: Colors.black.withOpacity(0.1),
offset: Offset(0,10)
),
],
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.cover,
image : NetworkImage("https://qph.fs.quoracdn.net/main-qimg-2b21b9dd05c757fe30231fac65b504dd")
),
),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
height: 40,
width: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
width: 4,
color: Theme.of(context).scaffoldBackgroundColor,
),
color: Colors.white
),
child: IconButton(
onPressed: () => Navigator.of(context).push(MaterialPageRoute(builder: (context)=>ImagePick())),
icon: Icon(Icons.camera_alt,color: Colors.blueAccent),),
),)
],
),
),
SizedBox(
height: 35,
),
TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.only(bottom: 3),
labelText: "Full Name",
floatingLabelBehavior: FloatingLabelBehavior.always,
hintText: "",
hintStyle: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
SizedBox(
height: 35,
),
TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.only(bottom: 3),
labelText: "Email",
floatingLabelBehavior: FloatingLabelBehavior.always,
hintText: "",
hintStyle: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
SizedBox(
height: 35,
),
TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.only(bottom: 3),
labelText: "Address",
floatingLabelBehavior: FloatingLabelBehavior.always,
hintText: "",
hintStyle: TextStyle(
fontSize: 16, fontWeight: FontWeight.bold,
color: Colors.black,
)
),
),
SizedBox(
height: 35,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
OutlineButton(
color: Colors.green,
padding: EdgeInsets.symmetric(horizontal: 50),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
onPressed: (){ Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context)=>MenuTry()));},
child: Text("CANCEL",style: TextStyle(
fontSize: 14, letterSpacing: 2.2, color: Colors.black,
),),
),
SizedBox(
height: 35,
),
OutlineButton(
color: Colors.green,
padding: EdgeInsets.symmetric(horizontal: 50),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>ImagePick()));
},
child: Text("SAVE",style: TextStyle(
fontSize: 14, letterSpacing: 2.2, color: Colors.black,
),),
),
],
)
],
),
),
),
);
}
}
class AlwaysDisabledFocusNode extends FocusNode {
#override
bool get hasFocus => false;
}
Widget Profile_UI(BuildContext context,String Full_Name,String Email,String Phone_Number,String Address) {
final data = MediaQuery.of(context);
return Container(
height: data.size.height,
padding: EdgeInsets.symmetric(
horizontal: 40.0,
vertical: 40.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Profile',
style: TextStyle(
color: Colors.white,
fontFamily: 'OpenSans',
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 30.0),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Your Full Name',
style: kLabelStyle,
),
SizedBox(height: 10.0),
Container(
alignment: Alignment.centerLeft,
decoration: kBoxDecorationStyle,
height: 60.0,
child: TextFormField(
initialValue: '$Full_Name',
enableInteractiveSelection: false,
focusNode: new AlwaysDisabledFocusNode(),
keyboardType: null,
style: TextStyle(
color: Colors.white,
fontFamily: 'OpenSans',
),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.only(top: 14.0),
prefixIcon: Icon(
Icons.account_box_rounded,
color: Colors.white,
),
hintText: 'No Data Available',
hintStyle: kHintTextStyle,
),
),
),
],
),
SizedBox(height: 20,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Your Email',
style: kLabelStyle,
),
SizedBox(height: 10.0),
Container(
alignment: Alignment.centerLeft,
decoration: kBoxDecorationStyle,
height: 60.0,
child: TextFormField(
initialValue: '$Email',
enableInteractiveSelection: false,
focusNode: new AlwaysDisabledFocusNode(),
keyboardType: null,
style: TextStyle(
color: Colors.white,
fontFamily: 'OpenSans',
),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.only(top: 14.0),
prefixIcon: Icon(
Icons.email,
color: Colors.white,
),
hintText: 'No Data Available',
hintStyle: kHintTextStyle,
),
),
),
],
),
SizedBox(height: 20,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Your Phone Number',
style: kLabelStyle,
),
SizedBox(height: 10.0),
Container(
alignment: Alignment.centerLeft,
decoration: kBoxDecorationStyle,
height: 60.0,
child: TextFormField(
initialValue: '$Phone_Number',
enableInteractiveSelection: false,
focusNode: new AlwaysDisabledFocusNode(),
keyboardType: null,
style: TextStyle(
color: Colors.white,
fontFamily: 'OpenSans',
),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.only(top: 14.0),
prefixIcon: Icon(
Icons.phone_android_rounded,
color: Colors.white,
),
hintText: 'No Data Available',
hintStyle: kHintTextStyle,
),
),
),
],
),
SizedBox(height: 20,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Your Address',
style: kLabelStyle,
),
SizedBox(height: 10.0),
Container(
alignment: Alignment.centerLeft,
decoration: kBoxDecorationStyle,
height: 60.0,
child: TextFormField(
initialValue: '$Address',
enableInteractiveSelection: false,
focusNode: new AlwaysDisabledFocusNode(),
keyboardType: null,
style: TextStyle(
color: Colors.white,
fontFamily: 'OpenSans',
),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.only(top: 14.0),
prefixIcon: Icon(
Icons.location_pin,
color: Colors.white,
),
hintText: 'No Data Available',
hintStyle: kHintTextStyle,
),
),
),
],
),
],
),
);
}
This is all of the error logs
W/DynamiteModule( 6389): Local module descriptor class for providerinstaller not found.
I/DynamiteModule( 6389): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller( 6389): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/System ( 6389): Ignoring header X-Firebase-Locale because its value was null.
W/System ( 6389): Ignoring header X-Firebase-Locale because its value was null.
D/FirebaseAuth( 6389): Notifying id token listeners about user ( xFM1dsh9BON1eWlIQYMQd96CI7H3 ).
E/flutter ( 6389): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
E/flutter ( 6389): #0 _ProfileState.initState.<anonymous closure> (package:mainflutter/screens/main_menu/profile.dart:40:18)
E/flutter ( 6389): #1 _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter ( 6389): #2 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 6389): #3 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter ( 6389): #4 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter ( 6389): #5 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter ( 6389): #6 Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter ( 6389): #7 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
E/flutter ( 6389): #8 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
E/flutter ( 6389): #9 Query.once (package:firebase_database/src/query.dart)
E/flutter ( 6389): <asynchronous suspension>
E/flutter ( 6389): #10 _ProfileState.initState (package:mainflutter/screens/main_menu/profile.dart:34:33)
E/flutter ( 6389): #11 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4812:57)
E/flutter ( 6389): #12 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4649:5)
E/flutter ( 6389): #13 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3615:14)
E/flutter ( 6389): #14 Element.updateChild (package:flutter/src/widgets/framework.dart:3377:20)
E/flutter ( 6389): #15 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
E/flutter ( 6389): #16 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #17 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6171:14)
E/flutter ( 6389): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #19 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
E/flutter ( 6389): #20 Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
E/flutter ( 6389): #21 StatelessElement.update (package:flutter/src/widgets/framework.dart:4756:5)
E/flutter ( 6389): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
E/flutter ( 6389): #24 Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
E/flutter ( 6389): #25 StatelessElement.update (package:flutter/src/widgets/framework.dart:4756:5)
E/flutter ( 6389): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
E/flutter ( 6389): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
E/flutter ( 6389): #29 ProxyElement.update (package:flutter/src/widgets/framework.dart:5033:5)
E/flutter ( 6389): #30 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
E/flutter ( 6389): #32 Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
E/flutter ( 6389): #33 ProxyElement.update (package:flutter/src/widgets/framework.dart:5033:5)
E/flutter ( 6389): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #35 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5693:32)
E/flutter ( 6389): #36 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6293:17)
E/flutter ( 6389): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
E/flutter ( 6389): #39 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4847:11)
E/flutter ( 6389): #40 Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
E/flutter ( 6389): #41 StatefulElement.update (package:flutter/src/widgets/framework.dart:4879:5)
E/flutter ( 6389): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #43 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4700:16)
E/flutter ( 6389): #44 Element.rebuild (package:flutter/src/widgets/framework.dart:4369:5)
E/flutter ( 6389): #45 ProxyElement.update (package:flutter/src/widgets/framework.dart:5033:5)
E/flutter ( 6389): #46 Element.updateChild (package:flutter/src/widgets/framework.dart:3367:15)
E/flutter ( 6389): #47 Compon
Any help would be lovely, thank you.
How can I apply different styles to the delivered and pending section lists?
I would like to change the color text of the status data.
Like status data pending Text should be red.
And status data delivered Text should be green.
How can I do this?
or I Should put this data manually? s
Code Bellow:
const delivered = [
{
id: 1,
title: 'Lanche, MADERO',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
{
id: 2,
title: 'McDonalds',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
{
id: 3,
title: 'Bobs',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
{
id: 4,
title: 'Burguer King',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
{
id: 5,
title: 'Outback',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
{
id: 6,
title: 'Esfiha',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
{
id: 7,
title: 'Habibs',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
{
id: 8,
title: 'McDonalds',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Delivered',
},
];
const pending = [
{
id: 1,
title: 'Sushi Garden',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Pending',
},
{
id: 2,
title: 'Gendai Sushi',
description: 'Rua Joao da silva, 22, 12 horas atrás',
status: 'Situação: Pending',
},
];
export default class LastOrders extends Component {
renderItem = ({item}) => (
<TouchableOpacity
onPress={() => {
const {navigation} = this.props;
navigation.navigate('OrderDetail');
}}>
<View style={styles.productContainer}>
<Text style={styles.productTitle}>{item.title}</Text>
<Text style={styles.productDescription}>{item.description}</Text>
<Text style={styles.productStatus}>{item.status}</Text>
</View>
</TouchableOpacity>
);
render() {
return (
<View style={styles.container}>
<SectionList
sections={[
{title: 'Entregas Pendentes', data: pending},
{title: 'Entregas Completas', data: delivered},
]}
renderItem={this.renderItem}
renderSectionHeader={({section}) => (
<View>
<Text style={styles.header}>{section.title}</Text>
</View>
)}
showsVerticalScrollIndicator={false}
keyExtractor={(item) => item.id}
/>
</View>
);
Styles Code Bellow:
import {StyleSheet} from 'react-native';
export default StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
list: {
padding: 20,
},
productContainer: {
backgroundColor: '#f5f5f5',
borderWidth: 1,
borderColor: '#fff',
borderRadius: 4,
padding: 20,
marginBottom: 20,
},
productTitle: {
fontSize: 18,
fontWeight: 'bold',
color: '#000',
},
productDescription: {
fontSize: 16,
color: '#999',
marginTop: 5,
lineHeight: 24,
},
productStatus: {
fontSize: 16,
color: 'red',
marginTop: 5,
lineHeight: 24,
},
header: {
fontWeight: 'bold',
fontSize: 20,
marginTop: 30,
marginLeft: 20,
},
});
You just have to set the style conditionally.
Your renderItem should be something like below, here I've compared the string directly, if you have some sort of ID for status better compare that.
renderItem = ({ item }) => (
<TouchableOpacity
onPress={() => {
const { navigation } = this.props;
navigation.navigate('OrderDetail');
}}>
<View style={styles.productContainer}>
<Text style={styles.productTitle}>{item.title}</Text>
<Text style={styles.productDescription}>{item.description}</Text>
<Text
style={
item.status === 'Situação: Pending'
? styles.productStatus
: styles.productStatusDelivered
}>
{item.status}
</Text>
</View>
</TouchableOpacity>
);
You will need a new style like this as well
productStatusDelivered: {
fontSize: 16,
color: 'green',
marginTop: 5,
lineHeight: 24,
},
I have created jqGrid in which i have to give color on row select but when i am trying to give for even rows, it's working fine but for odds rows it's not working.
I don't want to use jQuery or JavaScript i just want to do it from CSS. Is there way to achieve it?
Below is my sample code which is working for even rows:
.ui-jqgrid .ui-state-highlight:nth-child(even) { background: #d0e5f5; }
For odd rows its not working:
.ui-jqgrid .ui-state-highlight:nth-child(odd) { background: #d0e5f5; }
Sorry, but all works without any problem at me. Press "Run code snippet" button below and highlight odd or even rows on the demo
$(function () {
"use strict";
var mydata = [
{ id: "1", invdate: "2007-10-21", name: "test", note: "3note note note", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
{ id: "2", invdate: "2007-10-22", name: "test2", note: "3note2 note2", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
{ id: "3", invdate: "2007-09-01", name: "test3", note: "3note3 note3", amount: "400.00", tax: "30.00", closed: false, ship_via: "FE", total: "430.00" },
{ id: "4", invdate: "2007-10-14", name: "test4", note: "3note4", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
{ id: "5", invdate: "2007-10-31", name: "test5", note: "3note5", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
{ id: "6", invdate: "2007-09-06", name: "test6", note: "3note6", amount: "400.00", tax: "30.00", closed: false, ship_via: "FE", total: "430.00" },
{ id: "7", invdate: "2007-10-04", name: "test7", note: "3note7", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
{ id: "8", invdate: "2007-10-03", name: "test8", note: "3note8", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
{ id: "9", invdate: "2007-09-22", name: "test9 test9 test9 test9 test9", note: "3note9", amount: "400.00", tax: "30.00", closed: false, ship_via: "TN", total: "430.00" },
{ id: "10", invdate: "2007-09-08", name: "test10", note: "3note10", amount: "500.00", tax: "30.00", closed: true, ship_via: "TN", total: "530.00" },
{ id: "11", invdate: "2007-09-28", name: "test11", note: "3note11", amount: "500.00", tax: "30.00", closed: false, ship_via: "FE", total: "530.00" },
{ id: "12", invdate: "2007-09-10", name: "test12", note: "3note12", amount: "500.00", tax: "30.00", closed: false, ship_via: "FE", total: "530.00" }
],
initDatepicker = function (elem) {
$(elem).datepicker({
autoSize: true,
changeYear: true,
changeMonth: true,
showButtonPanel: true,
showWeek: true
});
},
numberTemplate = {formatter: "number", align: "right", sorttype: "number",
editrules: {number: true, required: true},
searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge", "nu", "nn", "in", "ni"] }},
$grid = $("#list");
$grid.jqGrid({
datatype: "local",
data: mydata,
colNames: ["Client", "Date", "Amount", "Tax", "Total", "Closed", "Shipped via", "Notes"],
colModel: [
{ name: "name", editrules: {required: true} },
{ name: "invdate", align: "center", sorttype: "date",
formatter: "date",
searchoptions: { sopt: ["eq", "ne", "lt", "le", "gt", "ge"], dataInit: initDatepicker } },
{ name: "amount", template: numberTemplate },
{ name: "tax", template: numberTemplate },
{ name: "total", template: numberTemplate },
{name: "closed", align: "center", formatter: "checkbox",
edittype: "checkbox", editoptions: {value: "Yes:No", defaultValue: "Yes"},
stype: "select", searchoptions: { sopt: ["eq", "ne"], value: ":Any;true:Yes;false:No" } },
{name: "ship_via", align: "center", formatter: "select",
edittype: "select", editoptions: { value: "FE:FedEx;TN:TNT;IN:Intim", defaultValue: "FE" },
stype: "select", searchoptions: { sopt: ["eq", "ne"], value: ":Any;FE:FedEx;TN:TNT;IN:Intim" } },
{ name: "note", sortable: false, search: false, edittype: "textarea" }
],
rowNum: 10,
rowList: [5, 10, 20],
pager: "#pager",
gridview: true,
rownumbers: true,
autoencode: true,
ignoreCase: true,
sortname: "invdate",
viewrecords: true,
sortorder: "desc",
shrinkToFit: false,
height: "auto"
});
});
.ui-jqgrid-hdiv { overflow-y: hidden; }
.ui-jqgrid .ui-state-highlight:nth-child(even) { background: #CCCCFF; }
.ui-jqgrid .ui-state-highlight:nth-child(odd) { background: #B2EC5D; }
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/redmond/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/css/ui.jqgrid.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/js/jquery.jqGrid.src.js"></script>
<table id="list"><tr><td></td></tr></table>
<div id="pager"></div>
I'm writing an app to interact with a DirecTV receiver through the http server interface. I'm able to query the device and get the SJON formatted response.
Here is my sample code:
- (NSDictionary *) readDVRData
{
NSMutableData *rData = [[NSMutableData alloc] initWithContentsOfFile:#"./data"];
//NSLog(#"rData = %#",rData);
NSString *rString = [[NSString alloc] initWithData:rData encoding:NSUTF8StringEncoding];
NSLog(#"rString = %#",rString);
NSError *error;
SBJSON *json = [[SBJSON new] autorelease];
NSDictionary *response = [json objectWithString:rString error:&error];
//NSLog(#"response = %#",response);
return response;
}
For testing purposes, I saved the response to the data file and I'm reading from it in the example above. The conversion from NSMutableData to NSString via:
NSString *rString = [[NSString alloc] initWithData:rData encoding:NSUTF8StringEncoding];
fails if the following character is in place. È as in CrÈme Fraiche. For reference this was in the episodeTitle and description from a South Park recording.
If I change this character to just an upper case "E", the conversion works. Is there a different method I should use to catch something like this? Or is there a simple way to remove characters like this? Please keep in mind I will not know before hand if it's and accent mark or something different that might cause the conversion to fail.
Thanks,
Dave
Snippet of data file if that is needed. I would include the entire text, but it pushes the character limit above the 30000 limit.
{
"groupId": "1 1 381C3",
"groupTitle": "South Park",
"isRecording": false,
"numItems": 10,
"numNewItems": 10,
"programs": [
{
"callsign": "COMHD",
"contentId": "1 1 381C3 198",
"description": "\"CrÈme Fraiche\" Animation, Comedy. (2010) Trey Parker, Matt Stone. Randy's obsession with the Food Network forces Sharon to explore a new interest of her own. Series.",
"duration": 1800,
"episodeTitle": "CrÈme Fraiche",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6937756",
"rating": "TV-MA-L",
"startTime": 1290056400,
"title": "South Park",
"uniqueId": "5397375192530140068"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 197",
"description": "\"Coon vs. Coon & Friends\" Animation, Comedy. (2010) Trey Parker, Matt Stone. Coon and Friends find themselves at the mercy of Cartman who now has the dark lord doing his bidding; Kenny wrestles with the curse of his super power. Series.",
"duration": 1800,
"episodeTitle": "Coon vs. Coon & Friends",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6918387",
"rating": "TV-MA-L",
"startTime": 1289444400,
"title": "South Park",
"uniqueId": "8476957599452610419"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 196",
"description": "\"Mysterion Rises\" Animation, Comedy. (2010) Trey Parker, Matt Stone. Mysterion's true identity is revealed; scorned by fellow superheroes, one goes out for revenge. Series.",
"duration": 1800,
"episodeTitle": "Mysterion Rises",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6896823",
"rating": "TV-MA-L",
"startTime": 1288843200,
"title": "South Park",
"uniqueId": "2113731123121326471"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 0",
"description": "Animation, Comedy. Trey Parker, Matt Stone. The adventures of four boys who live in South Park, Colo. Series.",
"duration": 1800,
"episodeTitle": "",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6830127",
"rating": "TV-MA-L",
"startTime": 1288751400,
"title": "South Park",
"uniqueId": "2166056034991125062"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 195",
"description": "\"Coon 2: Hindsight\" Animation, Comedy. (2010) Trey Parker, Matt Stone. Coon and friends set out to help the victims of BP's latest catastrophic drilling accident in the Gulf. Series.",
"duration": 1800,
"episodeTitle": "Coon 2: Hindsight",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6876407",
"rating": "TV-MA-L",
"startTime": 1288238400,
"title": "South Park",
"uniqueId": "8615834721021879366"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 194",
"description": "\"Insheeption\" Animation, Comedy. (2010) Trey Parker, Matt Stone. When Stan is sent to the school counselor because he's holding on to an obscene number of useless possessions, he realizes that Mr. Mackey had a hoarding disorder too. Series.",
"duration": 1783,
"episodeTitle": "Insheeption",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6857628",
"rating": "TV-MA-L",
"startTime": 1287626416,
"title": "South Park",
"uniqueId": "1547798106243799673"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 193",
"description": "\"It's a Jersey Thing\" Animation, Comedy. (2010) Trey Parker, Matt Stone. New Jersey is taking over the nation one state at a time, Randy and the boys take a stand as the Jerseyites approach South Park. Series.",
"duration": 1800,
"episodeTitle": "It's a Jersey Thing",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6839243",
"rating": "TV-MA-L",
"startTime": 1287028800,
"title": "South Park",
"uniqueId": "8123622337314668826"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 193",
"description": "\"It's a Jersey Thing\" Animation, Comedy. (2010) Trey Parker, Matt Stone. New Jersey is taking over the nation one state at a time, Randy and the boys take a stand as the Jerseyites approach South Park. Series.",
"duration": 1784,
"episodeTitle": "It's a Jersey Thing",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6839243",
"rating": "TV-MA-L",
"startTime": 1287021615,
"title": "South Park",
"uniqueId": "949183344652655207"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 0",
"description": "Animation, Comedy. Trey Parker, Matt Stone. The adventures of four boys who live in South Park, Colo. Series.",
"duration": 1800,
"episodeTitle": "",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6830127",
"rating": "TV-MA-L",
"startTime": 1286937000,
"title": "South Park",
"uniqueId": "7841891672059226043"
},
{
"callsign": "COMHD",
"contentId": "1 1 381C3 0",
"description": "Animation, Comedy. Trey Parker, Matt Stone. The adventures of four boys who live in South Park, Colo. Series.",
"duration": 1800,
"episodeTitle": "",
"expiration": "0",
"isHd": true,
"isPartial": false,
"isPpv": false,
"isRecording": false,
"isViewed": false,
"isVod": false,
"keepUntilFull": true,
"major": 249,
"minor": 65535,
"programId": "6830127",
"rating": "TV-MA-L",
"startTime": 1286856000,
"title": "South Park",
"uniqueId": "3872435936942587460"
}
]
}
Have you tried other encodings, such as NSISOLatin1StringEncoding?
It's likely an encoding problem from the web server. You're expecting UTF-8 data, but I bet you that's not what they are sending you. Try reading using [NSString stringWithContentsOfFile:] instead and see if anything changes.
The compiler will throw a warning because that method is deprecated. In fact, you could use stringWithContentsOfFile:usedEncoding:error: instead, but I and others have reported that it doesn't seem to work as well as the old method for data that is not perfectly encoded (that is, 90% of the web :-)).
Check the HTTP headers in the DirecTV unit's response. It is probably not using UTF-8. Figure out which encoding it is using, then supply the correct constant to initWithData:encoding:.
You can use the command curl -i http://directv-data-url to see the HTTP headers.