Firebase e Java - firebase

Why in some cases, the firebase node is created as a string with double quotes "" and in another cases as a string with no quotes.
for example:
----dates
|
022022--
|
"022022"--
Thanks for the help

I solved the problem by simply adding the .trim() method to myString before calling the save command. Example:
movimentacoes_ref = firebaseref
.child("movimentacao")
.child(id_Usuario)
.child(mesAno); // give me a "mesAno" node in firebase.
and
movimentacoes_ref = firebaseref
.child("movimentacao")
.child(id_Usuario)
.child(mesAno.trim()); // give me a mesAno node in firebase.

Related

aws dynamodb query attribute value that contains special character?

attribute itemJson stored as follow
"itemJson": {
"S": "{\"sold\":\"3\",\"listingTime\":\"20210107211621\",\"listCountry\":\"US\",\"sellerCountry\":\"US\",\"currentPrice\":\"44.86\",\"updateTime\":\"20210302092220\",\"itemLocation\":\"Miami,FL,USA\",\"listType\":\"FixedPrice\",\"categoryName\":\"Machines\",\"itemID\":\"293945109477\",\"sellerID\":\"holiday_for_you\",\"s3Key\":\"US/2021/2/FixedPrice/293945109477.json\",\"visitCount\":\"171\",\"createTime\":\"20210201233158\",\"listingStatus\":\"Completed\",\"endTime\":\"2021-02-28T20:22:57\",\"currencyID\":\"USD\"}"
},
i want to query with filter:contains(itemJson, "sold":"0") with java sdk,i tried those syntax,all fail
expressionValues.put(":v2", AttributeValue.builder().s("\\\"sold\\\":\\\"0\\\"").build());
expressionValues.put(":v2", AttributeValue.builder().s("sold:0"").build());
what is the right way to my filter syntax?
I try #Balu Vyamajala's syntax on the dynamodb web console as follow,did not get the solution yet
contains (itemJson, :subValue) with value of "sold\":\"3\"" seems to be working.
Working example on a Query Api and worked as expected:
QuerySpec querySpec = new QuerySpec()
.withKeyConditionExpression("pk = :v_pk")
.withFilterExpression("contains (itemJson, :subValue)")
.withValueMap(new ValueMap().withString(":v_pk", "6").withString(":subValue", "sold\":\"3\""));
and to test from Aws console we just need to enter "sold":"2"

Something adds a dot at the end of my Firebase query

I have a List of favorites ID's, that I'm fetching from Firebase.
The first of the list is fetched normally, the problem is that on the second ID "something" adds a dot at the end of the string becoming "Vd$r367Tyuezjphk4699sd." from "Vd$r367Tyuezjphk4699sd"
The method I use is:
_getFavorites(favorites) async {
for (var i = 0; i < favorites.length; i++) {
var id = favorites[i];
print('HERE ID ID ID $id');
final dbRef = FirebaseDatabase.instance.reference().child('favorites').child(id);
var snapshot = await dbRef.once();
the print('HERE ID ID ID $id'); gives the correct ID:
HERE ID ID ID Vd$r367Tyuezjphk4699sd
and then the next output line is:
E/MethodChannel#plugins.flutter.io/firebase_database(2756979): Failed to
handle method call
E/MethodChannel#plugins.flutter.io/firebase_database(2756979):
com.google.firebase.database.DatabaseException: Invalid Firebase
Database path: favorites/Vd$r367Tyuezjphk4699sd.
Firebase Database paths must not contain '.', '#', '$', '[', or ']'
Anyone have an idea what's going on here? I would appreciate any help with this. Thanks!
Ok it seems that the problem is the $ symbol not the dot. The dot is there to indicate the end of the sentence, but that "Firebase Database paths must not contain '.', '#', '$', '[', or ']'" confused me and made me think, that the dot is the problem. Then I saw the $ in the given ID and it's there, because Ive added some dummy data.

Passing Array parameter to SQLiteObject.executeSql()

I'm trying to pass an array parameter to the function executeSql of SQLiteObject in ionic to make it as a value for my sql query.
For example
var sqlQuery: string = "SELECT * FROM Property WHERE ID IN (?) AND Status = ?"
var ids: number[] = [123, 321, 456];
and I'm trying to pass it here,
var db: SQLiteObject
db.executeSql(sqlQuery, [ids, 0])
So basically I want to insert all the values of ids to the IN operator and 0 for Status. But I think the SQL interprets it differently.
I tried to pass it as a string db.executeSql(sqlQuery, [ids.toString(), 0]) to remove the unnecessary characters and such. But still it doesn't return anything.
NOTE
I know I need it to enclose to a promise or something, but I just sliced it and summarize it to remove the unnecessary codes. Thanks.
I tried to search all over but still can't find a definite answer, I just invent a work around for it by doing this method.
var ids: number[] = [123, 321, 456];
var sqlQuery: string = "SELECT * FROM Property WHERE ID IN (" + ids.toString() + ") AND Status = ?";
And pass it to executeSql function
var db: SQLiteObject
db.executeSql(sqlQuery, [0]);
This is just a work around. I'll still wait for a better solution. Thanks!

json.net SelectToken with embedded "."

I have json that looks like:
myjson = {"queries":{"F.SP": 27}}
so with
queryResults = JObject.Parse(jsonString)
I can do
firstToken = queryResults.SelectToken("queries")
and get back the LinqJToken
{"F.SP": 27}
but I'm then stuck, because when I try
subToken = firstToken.SelectToken("F.SP")
I get Nothing. I'm guessing this is because JSON.net is looking for a token "F" with subtoken "SP".
I've also tried each of the following, to no avail
myToken = queryResults.SelectToken("queries.F.SP")
myToken = queryResults.SelectToken("queries[0].F.SP")
(queryResults.SelectToken("queries[0]") returns nothing, fwiw)
Any ideas?
EDIT: I have verified that the embedded "." is the problem; if I change the original json to
{"queries":{"FSP": 27}}
I can do
queryResults.SelectToken("queries").SelectToken("FSP")
no problem
If you have such names in JSON fields:
{"queries":{"F.SP": 27}}
You may use SelectToken escaping:
queryResults.SelectToken("queries").SelectToken("['F.SP']")
or
queryResults.SelectToken("queries.['F.SP']")
Here are more examples with escaping: http://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenEscaped.htm
This won't return the token itself, but will return the value (which is probably what you're looking for anyway)...
queryResults.SelectToken("queries").Value<int>("F.SP");
Instead of trying to use SelectToken, how about an index search?
subToken = queryResults["F.SP"];
JObject obj = JObject.Parse(jsonstring);
var fsp = obj["queries"].First().First();
Not the most elegant but it gets the value.

How to insert complex strings into Actionscript?

How to insert complex strings into Actionscript?
So I have a string
-vvv -I rc w:// v dv s="60x40" --ut="#scode{vcode=FV1,acode=p3,ab=128,ch=2,rate=4400}:dup{dt=st{ac=http{mime=v/x-flv},mux=mpeg{v},dt=:80/sm.fv}}"
How to insert it into code like
public var SuperPuperComplexString:String = new String();
SuperPuperComplexString = TO_THAT_COMPLEX_STRING;
That string has so many problems like some cart of it can happen to be like regexp BUTI DO NOT want it to be parsed as any kind of reg exp - I need It AS IT IS!)
How to put that strange string into variable (put it not inputing it thru UI - hardcode it into AS code)?
SInce the only problem characters in your string are the double quotes ( " " ), just enclose your String in single quotes ( ' ' ). That will solve any problems.
It also depends on how you are loading that string into your code, as well.
You could even go so far as to encase that String in XML CDATA to ensure it's all delimited for when you want to use it.
var myString:XML = new XML();
myString = "<string><![CDATA[-vvv -I rc w:// v dv s="60x40" --ut="#scode{vcode=FV1,acode=p3,ab=128,ch=2,rate=4400}:dup{dt=st{ac=http{mime=v/x-flv},mux=mpeg{v},dt=:80/sm.fv}}"]]></string>"
Then, you can access it as a string from anywhere by just referencing myString.
var myString:String = '-vvv -I rc w:// v dv s="60x40" --ut="#scode{vcode=FV1,acode=p3,ab=128,ch=2,rate=4400}:dup{dt=st{ac=http{mime=v/x-flv},mux=mpeg{v},dt=:80/sm.fv}}"'
Not sure where your problem is..

Resources