Long Query String Being Split - json

I'm using the query string to pass data between two PhoneApplicationPages but the destination page is recieving the data as multiple paameters instead of one big string. This is a problem as I'm passing data as JSON which cannot be desrialized if it's truncated mid flow.
The data I'm passing is:
NavigationService.Navigate("/MainPage.xaml?view=recipes&searchargs={"Author":null,"AuthorFilterType":2,"Categories":["1 Point","100-200 Calorie","1-3 grams Fat","3 Point","Baked Snack","Bakery & Baked Products","Banana","Beer","Boutique Wines","Bread","Breakfast","Breakfast Drinks","Cake","Cakes","Cocktails","Collectible Wines","Cookie","Cookie Dessert","Dairy","Dessert","Desserts","Diabetic","Drinks & Beverages","Fruit","Fruit Dessert","Fruit Drinks","Fruits","Gluten Free","High Fiber","Main Course","Main dish","Pasta","Pork","Raw Foods","Salads","Sandwiches","Shake & Smoothie","Side dish","Snack","Strawberry","Sweet Snack","Under 1 gram Fat","Under 100 Calorie","Vegetarian","Weight Watchers Points","Yogurt"],"Countries":[],"GlobalSearch":"","Ingredients":[],"MaxIngredients":0,"MinIngredients":0,"Name":null,"NameFilterType":2,"Rating":0,"Types":[]}");
But the query string contains this:
Is this a bug?

you need to escape the " used by json try this
NavigationService.Navigate("/MainPage.xaml?view=recipes&searchargs={\"Author\":null,\"AuthorFilterType\":2,\"Categories\":[\"1 Point\",\"100-200 Calorie\",\"1-3 grams Fat\",\"3 Point\",\"Baked Snack\",\"Bakery & Baked Products\",\"Banana\",\"Beer\",\"Boutique Wines\",\"Bread\",\"Breakfast\",\"Breakfast Drinks\",\"Cake\",\"Cakes\",\"Cocktails\",\"Collectible Wines\",\"Cookie\",\"Cookie Dessert\",\"Dairy\",\"Dessert\",\"Desserts\",\"Diabetic\",\"Drinks & Beverages\",\"Fruit\",\"Fruit Dessert\",\"Fruit Drinks\",\"Fruits\",\"Gluten Free\",\"High Fiber\",\"Main Course\",\"Main dish\",\"Pasta\",\"Pork\",\"Raw Foods\",\"Salads\",\"Sandwiches\",\"Shake & Smoothie\",\"Side dish\",\"Snack\",\"Strawberry\",\"Sweet Snack\",\"Under 1 gram Fat\",\"Under 100 Calorie\",\"Vegetarian\",\"Weight Watchers Points\",\"Yogurt\"],\"Countries\":[],\"GlobalSearch\":\"\",\"Ingredients\":[],\"MaxIngredients\":0,\"MinIngredients\":0,\"Name\":null,\"NameFilterType\":2,\"Rating\":0,\"Types\":[]}");

Thanks #Hermit Dave. For reference, the methods are Uri.EscapeDataString() and Uri.UnescapeDataString().

Related

Extract string from csv file after reading in Prolog

Good evening,
I am trying to read a csv file in Prolog containing all the countries in the world. Executing this code:
read_KB(R) :- csv_read_file("countries.csv",R).
I get a list of Terms of this type:
R = [row('Afghanistan;'), row('Albania;'), row('Algeria;'), row('Andorra;'), row('Angola;'), row('Antigua and Barbuda;'), row('Argentina;'), row('Armenia;'), row(...)|...].
I would like to extract only the names of each country in form of a String and put all of them into a list of Strings.
I tried this way with only the first row executing this:
read_KB(L) :- csv_read_file("/Users/dylan/Desktop/country.csv",R),
give(R,L).
give([X|T],X).
I obtain only a Term of type row('Afghanistan;')
You can use maplist/3:
read_KB(Names) :-
csv_read_file('countries.csv', Rows, [separator(0';)]),
maplist([row(Name,_), Name] >> true, Rows, Names).
The answer given by #slago can be simplified, using arg/3 instead of a lambda expression, making it slightly more efficient:
read_KB(Names) :-
csv_read_file('countries.csv', Rows, [separator(0';)]),
maplist(arg(1), Rows, Names).

flutter: how to make list from mysql-data?

From the MySQL query I get data like this:
(Fields: {IDAufgaben: 2630, Aufgabe: erste Aufgabe},
Fields: {IDAufgaben: 2627, Aufgabe: Testen})
json.decode gives a FormatException — I think because the quotes are lacking.
How can I change the MySQL data received in a Dart list?
Thanks a lot for help, I am newbie in Flutter and Dart…
should quote marks too, but if you take it from the terminallog then what happens is the quotation tent is not included, the solution is to change to json using jsonencode
like this one :
final myfiled = {"IDAufgaben": "2630", "Aufgabe": "erste Aufgabe"};
print(JsonEncoder.withIndent(" ").convert(myfiled));
/// result terminal is :
{
"IDAufgaben": "2630",
"Aufgabe": "erste Aufgabe"
}

How to parse a string in MySQL

So the problem is I have a column that contains a snapshot:
<p>
<t8>xx</t8>
<s7>321</s7>
<s1>6</s1>
<s2>27</s2>
<s4>73</s4>
<t1>noemail#noemail.com</t1>
<t2>xxxxx</t2>
<t3>xxxxxx</t3>
<t11>xxxxxxxx</t11>
<t6>xxxxxxxx</t6>
<t7>12345</t7>
<t9>1234567890</t9>
</p>
I need to parse this string in MySQL so that I can count the number of times that noemail.com occurs. I am not familiar with parsing so if you could please explain the best you can.
You can do it by removing searched substring and comparing the lengths. For example :
set #str = '<p>
<t8>xx</t8>
<s7>321</s7>
<s1>6</s1>
<s2>27</s2>
<s4>73</s4>
<t1>noemail#noemail.com</t1>
<t2>xxxxx</t2>
<t3>xxxxxx</t3>
<t11>xxxxxxxx</t11>
<t6>xxxxxxxx</t6>
<t7>12345</t7>
<t9>1234567890</t9>
</p>';
set #find = 'noemail#noemail.com';
select (length(#str) - length(replace(#str, #find, '')))/length(#find) AS NumberOfTimesEmailAppears;
I think there is sadly no more elegant solution (note that a database system is not designed to parse strings : this is most the job of a scripting language)

json_encoded String that cannot appear to be decoded

I have successfully produced the json representation below for one custom object. However, when I use json_decode(jsonObjectBelow) I am not successfully in converting it to an array. I have finally found out why this has happened. If I delete characters with accents e.g "Muñoz-Gómez", then the json_decode(jsonObjectBelow) works, and I am able to generate my array and extract the attributes. For practical purposes, I cannot scour all the attributes and removing these accents...Is there a solution?
json_object received: [{"abstractText":"Fevers of unknown origin (FUOs) may be due to any of over 200 different disorders. We present a most unusual case of an FUO in a returning traveler from the Dominican Republic. Work-up for Q fever, Brucellosis, Bartonella, malaria and HIV were negative, but very highly elevated ESRs and ferritin levels suggested possible Legionnaire\u0027s disease. This is the third reported case of Legionnaire\u0027s disease presenting as an FUO.","authorString":"Muñoz-Gómez S, Cunha BA.","issue":"1","journalTitle":"Heart Lung","pageInfo":"72-74","pmid":"25444558","pubYear":"2015","title":"Fever of unknown origin (FUO) due to Legionnaire\u0027s disease.","volume":"44"}]
This code works for text in attributes that have not got accents, but does not work for text with accents.
My php code:
//Get JSON POST
$json = $_POST["jsonObj"];
//Decode JSON into an Array
$data = json_decode($json);
for($i = 0; $i<count($data); $i++){
echo "[".$i."]" . " " .$data[$i]->authorString . "/ " . $data[$i]->journalTitle . "<br>";
}
if possible try to encode the values and the send the json object. Try the steps in the following link:
UTF-8 character encoding battles json_encode()

JMeter While Controller with CSV issue

I've got an issue with the Loop controller in Jmeter when using a CSV reader which hopefully someone can shed some light on for me.
So I have a CSV file which contains a bunch of currency codes and their respective names (See below), I'm then using the CSV values in a subsequent HTTP Request.
ALL,Albanian Lek
DZD,Algerian Dinar
ARS,Argentine Peso
AMD,Armenian Dram
AUD,Australian Dollar
AZN,Azerbaijan New Manat
BSD,Bahamian Dollar
BHD,Bahraini Dinar
BDT,Bangladeshi Taka
BZD,Belize Dollar
BOB,Bolivian Boliviano
BRL,Brazilian Real
GBP,British Pound
BND,Brunei Dollar
XOF,CFA Franc BCEAO
XAF,CFA Franc BEAC
XPF,CFP Franc
KHR,Cambodian Riel
CAD,Canadian Dollar
CLP,Chilean Peso
CNY,Chinese Yuan Renminbi
COP,Colombian Peso
KMF,Comoros Franc
CRC,Costa Rican Colon
HRK,Croatian Kuna
CZK,Czech Koruna
DKK,Danish Krone
DJF,Djibouti Franc
DOP,Dominican R. Peso
XCD,East Caribbean Dollar
EGP,Egyptian Pound
EEK,Estonian Kroon
EUR,Euro
FJD,Fiji Dollar
HNL,Honduran Lempira
HKD,Hong Kong Dollar
HUF,Hungarian Forint
ISK,Iceland Krona
INR,Indian Rupee
IDR,Indonesian Rupiah
ILS,Israeli New Shekel
JPY,Japanese Yen
JOD,Jordanian Dinar
KZT,Kazakhstan Tenge
KES,Kenyan Shilling
KWD,Kuwaiti Dinar
KGS,Kyrgyzstanian Som
LAK,Lao Kip
LVL,Latvian Lats
LBP,Lebanese Pound
LTL,Lithuanian Litas
MYR,Malaysian Ringgit
MRO,Mauritanian Ouguiya
MUR,Mauritius Rupee
MXN,Mexican Peso
MNT,Mongolian Tugrik
MAD,Moroccan Dirham
NAD,Namibia Dollar
NPR,Nepalese Rupee
NZD,New Zealand Dollar
NIO,Nicaraguan Cordoba Oro
NOK,Norwegian Kroner
OMR,Omani Rial
PKR,Pakistan Rupee
PGK,Papua New Guinea Kina
PYG,Paraguay Guarani
PEN,Peruvian Nuevo Sol
PHP,Philippine Peso
PLN,Polish Zloty
QAR,Qatari Rial
RON,Romanian New Lei
RUB,Russian Rouble
RWF,Rwandan Franc
WST,Samoan Tala
SAR,Saudi Riyal
SGD,Singapore Dollar
SOS,Somali Shilling
ZAR,South African Rand
KRW,South-Korean Won
LKR,Sri Lanka Rupee
SZL,Swaziland Lilangeni
SEK,Swedish Krona
CHF,Swiss Franc
TWD,Taiwan Dollar
TZS,Tanzanian Shilling
THB,Thai Baht
TND,Tunisian Dinar
TRY,Turkish Lira
USD,US Dollar
UGX,Uganda Shilling
UAH,Ukraine Hryvnia
UYU,Uruguayan Peso
AED,Utd. Arab Emir. Dirham
VUV,Vanuatu Vatu
VEF,Venezuelan Bolivar
VND,Vietnamese Dong
ZMK,Zambian Kwacha
In my While Loop I have a the following conditional check:
${__javaScript("EOF" != "${currencyCode}")}
note I have stackoverflow doesnt seem to display the angle brackets but there are there in my JMeter
So what I'm seeing is that the loop is going through the CSV and the required HTTP Request is being sent. However once the last value in the CSV value ("ZMK" in this case) is reached a extra Request is being made with a value of
So it looks like the Whileis doing one more loop than it should be.
I've checked the CSV file in VIM and every other editor I could think of and there are no blank lines or tabs at the end of the CSV file.
If I make my Loop condition
${__javaScript("ZMK" != "${currencyCode}")}
everything works fine. But the CSV could grow so I dont want to hardcode anything.
Just to give you a better picture of my test here is the overall picture
+ Thread Group
++ Simple Controller
+++ While Loop with condition ${__javaScript("<EOF>" != "${currencyCode}")}
++++ CSV Reader (Recycle on EOF = FALSE, STOP THREAD ON EOF = FALSE, SHARING = Current Thread)
++++ HTTP Request using value from CSV file
Also my
Try putting your CSV reader all the way at the top of the testplan. It is below your While controller now which is causing this issue.
Try totally removing your While Controllerand providing a reasonable number of Loops in Thread group (or alternatively replace it with Loop Controller)
Also, you should make your CSV Data Set Config a child of HTTP Request. See Using CSV DATA SET CONFIG guide for more details on how to implement CSV reading logic in JMeter.
Another option is using Beanshell to retrieve all currency codes and local names and store them to JMeter variables.
Following Beanshell code will obtain all currencies available in Java and store them to JMeter Variables
Set<Currency> currencies = Currency.getAvailableCurrencies();
for (Currency currency : currencies) {
vars.put(currency.getCurrencyCode(), currency.getDisplayName());
}
${__javaScript("${currencyCode}" != "EOF",)}
Worked with me.
Put your CSV reader at the top of the testplan as a child of a while controller with the following condition(function or variable): ${__javaScript(“${currencyCode}” != “<EOF>”,)}.
Then you have to increase the number of threads of your thread group to the number of rows in your CSV file, this way it will loop over each line in the csv file with each thread.