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"
}
I am currently sending compressed messages through Kafka Producer by enabling the compression using following properties:
compression.type="gzip"
compressed.topics="Topic_A, Topic_B"
When the kafkaproducer object is instantiated the following list of properties are listed in ProducerConfig object:
{compression.type=gzip, metric.reporters=[], metadata.max.age.ms=300000, metadata.fetch.timeout.ms=60000, reconnect.backoff.ms=50, sasl.kerberos.ticket.renew.window.factor=0.8, bootstrap.servers=[MyServer_IP:9092], retry.backoff.ms=100, sasl.kerberos.kinit.cmd=/usr/bin/kinit, buffer.memory=33554432, timeout.ms=30000, key.serializer=class org.apache.kafka.common.serialization.StringSerializer, sasl.kerberos.service.name=null, sasl.kerberos.ticket.renew.jitter=0.05, ssl.keystore.type=JKS, ssl.trustmanager.algorithm=PKIX, block.on.buffer.full=false, ssl.key.password=null, max.block.ms=60000, sasl.kerberos.min.time.before.relogin=60000, connections.max.idle.ms=540000, ssl.truststore.password=null, max.in.flight.requests.per.connection=5, metrics.num.samples=2, client.id=, ssl.endpoint.identification.algorithm=null, ssl.protocol=TLS, request.timeout.ms=30000, ssl.provider=null, ssl.enabled.protocols=[TLSv1.2, TLSv1.1, TLSv1], acks=1, batch.size=16384, ssl.keystore.location=null, receive.buffer.bytes=32768, ssl.cipher.suites=null, ssl.truststore.type=JKS, security.protocol=PLAINTEXT, retries=0, max.request.size=1048576, value.serializer=class org.apache.kafka.common.serialization.ByteArraySerializer, ssl.truststore.location=null, ssl.keystore.password=null, ssl.keymanager.algorithm=SunX509, metrics.sample.window.ms=30000, partitioner.class=class org.apache.kafka.clients.producer.internals.DefaultPartitioner, send.buffer.bytes=131072, linger.ms=0}
Problem:
In this list "compression.type=gzip" is clearly set as required but "compressed.topics" is missing. It results in enabling compressions for all topics but I need it on selective ones.
Findings:
I debug the code and came to know that in ProducerConfig.java class "compressed.topics" property is not defined due to that when KafkaProducer object is instantiated it does not have the required property.
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)
i'm trying to convert it to json via jiffy and get an exception, seem that its correct
{"PurchaseOrder",
[{"PurchaseOrderNumber","99503"},
{"OrderDate","1999-10-20"},
{"Address",
[[{"Type","Shipping"},
{"Name",[{<<"#text">>,"Ellen Adams"}]},
{"Street",[{<<"#text">>,"123 Maple Street"}]},
{"City",[{<<"#text">>,"Mill Valley"}]},
{"State",[{<<"#text">>,"CA"}]},
{"Zip",[{<<"#text">>,"10999"}]},
{"Country",[{<<"#text">>,"USA"}]}],
[{"Type","Billing"},
{"Name",[{<<"#text">>,"Tai Yee"}]},
{"Street",[{<<"#text">>,"8 Oak Avenue"}]},
{"City",[{<<"#text">>,"Old Town"}]},
{"State",[{<<"#text">>,"PA"}]},
{"Zip",[{<<"#text">>,"95819"}]},
{"Country",[{<<"#text">>,"USA"}]}]]},
{"DeliveryNotes",
[{<<"#text">>,"Please leave packages in shed by driveway."}]},
{"Items",
[{"Item",
[[{"PartNumber","872-AA"},
{"ProductName",[{<<"#text">>,"Lawnmower"}]},
{"Quantity",[{<<"#text">>,"1"}]},
{"USPrice",[{<<"#text">>,"148.95"}]},
{"Comment",[{<<"#text">>,"Confirm this is electric"}]}],
[{"PartNumber","926-AA"},
{"ProductName",[{<<"#text">>,"Baby Monitor"}]},
{"Quantity",[{<<"#text">>,"2"}]},
{"USPrice",[{<<"#text">>,"39.98"}]},
{"ShipDate",[{<<"#text">>,"1999-05-21"}]}]]}]}]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
help please, what's wrong?
Put your proplists/objects in tuple
instead of [{a,b}] should be {[{a,b}]}
Use binary strings instead of lists
instead of "string" should be <<"string">>
Rtfm on jiffy data format: https://github.com/davisp/jiffy#data-format
Example:
{[{<<"PurchaseOrder">>,
{[{<<"PurchaseOrderNumber">>,<<"99503">>},
{<<"OrderDate">>,<<"1999-10-20">>},
{<<"Address">>,
[{[{<<"Type">>,<<"Shipping">>},
{<<"Name">>,{[{<<"#text">>,<<"Ellen Adams">>}]}},
{<<"Street">>,{[{<<"#text">>,<<"123 Maple Street">>}]}},
{<<"City">>,{[{<<"#text">>,<<"Mill Valley">>}]}},
{<<"State">>,{[{<<"#text">>,<<"CA">>}]}},
{<<"Zip">>,{[{<<"#text">>,<<"10999">>}]}},
{<<"Country">>,{[{<<"#text">>,<<"USA">>}]}}]},
{[{<<"Type">>,<<"Billing">>},
{<<"Name">>,{[{<<"#text">>,<<"Tai Yee">>}]}},
{<<"Street">>,{[{<<"#text">>,<<"8 Oak Avenue">>}]}},
{<<"City">>,{[{<<"#text">>,<<"Old Town">>}]}},
{<<"State">>,{[{<<"#text">>,<<"PA">>}]}},
{<<"Zip">>,{[{<<"#text">>,<<"95819">>}]}},
{<<"Country">>,{[{<<"#text">>,<<"USA">>}]}}]}]},
{<<"DeliveryNotes">>,
{[{<<"#text">>,<<"Please leave packages in shed by driveway.">>}]}},
{<<"Items">>,
{[{<<"Item">>,
[{[{<<"PartNumber">>,<<"872-AA">>},
{<<"ProductName">>,{[{<<"#text">>,<<"Lawnmower">>}]}},
{<<"Quantity">>,{[{<<"#text">>,<<"1">>}]}},
{<<"USPrice">>,{[{<<"#text">>,<<"148.95">>}]}},
{<<"Comment">>,{[{<<"#text">>,<<"Confirm this is electric">>}]}}]},
{[{<<"PartNumber">>,<<"926-AA">>},
{<<"ProductName">>,{[{<<"#text">>,<<"Baby Monitor">>}]}},
{<<"Quantity">>,{[{<<"#text">>,<<"2">>}]}},
{<<"USPrice">>,{[{<<"#text">>,<<"39.98">>}]}},
{<<"ShipDate">>,{[{<<"#text">>,<<"1999-05-21">>}]}}]}]}]}}]}}]}
Hay all,
I am using Kohana 3 and I am attempting to integreate the jquery fullcarlendar plugin. The naming conventions used for this plugin seems to be "title" for the event, "start" for the start date, "allday" for a boolean, and so on.
After querying I generated a json string like
[{"eventdate":"2011-02-05 06:15:35","name":"EBS, Heriot Watt Graduation Ceremony"},{"eventdate":"2011-02-05 06:16:20","name":"Heriot Watt University Edinburgh Business School Graduation Ceremony 2011"}]
Is there a way to do something like
DB::select('start'=>'simpleevent.eventdate', 'title'=>'simpleevent.name')
->from('simpleevent')
->where('YEAR("eventdate")', '=', $todayasarray[0])
Basically after the query I get an array of arrays in PHP which is then used in
json_encode($myArray)
So can I rename the "name" for each name/value pair?
`
DB::select(array('simpleevent.eventdate', 'start'), array('simpleevent.name', 'title'))
->from('simpleevent')
->where( /*condition*/)
I tried this, basically after creating the json as a string on my action I used the php str_replace() function as follows.
$oldnames = array("name","eventdate");
$newnames = array("title","start");
$v->jsonData = str_replace($oldnames, $newnames, $jsondata);
This is an option only if you cannot make the alias change as shown above by Dusan