soapbox / laravel-formatter Goto Github PK
View Code? Open in Web Editor NEWThis project forked from studiofrenetic/laravel-formatter
A Formatter Class for Laravel 4 based on FuelPHP's Formatter Class
This project forked from studiofrenetic/laravel-formatter
A Formatter Class for Laravel 4 based on FuelPHP's Formatter Class
Is there a way to set a basenode for toXml like you could with to_xml() in the previous version?
Refuses to install on Laravel 5.6
Using version ^3.0 for soapbox/laravel-formatter
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for soapbox/laravel-formatter ^3.0 -> satisfiable by soapbox/laravel-formatter[3.0].
- Conclusion: remove laravel/framework v5.6.16
- Conclusion: don't install laravel/framework v5.6.16
- soapbox/laravel-formatter 3.0 requires illuminate/support 5.5.x -> satisfiable by illuminate/support[5.5.x-dev, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40].
- illuminate/support 5.5.x-dev conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.0 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.16 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.17 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.2 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.28 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.35 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.36 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.37 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.39 conflicts with laravel/framework[v5.6.16].
- illuminate/support v5.5.40 conflicts with laravel/framework[v5.6.16].
- don't install illuminate/support v5.5.33|don't install laravel/framework v5.6.16
- don't install illuminate/support v5.5.34|don't install laravel/framework v5.6.16
- Installation request for laravel/framework (locked at v5.6.16, required as 5.6.*) -> satisfiable by laravel/framework[v5.6.16].
Hi, I am using laravel 5.2, and need to convert complex xml to json/array. So I need to know, will it work with 5.2?
When the formatter is used as a service, e.g.:
$data['ids'] = '1,2,3';
$results = Formatter::make($data['ids'], 'csv')->to_array();
The result is an empty array while is should return an array contains element 1, 2 and 3.
I published the config file via artisan, but the config for csv is never read, it alway takes the fallback values in the script. I can't pass attributes either, because they aren't passed through.
Say I want a XML like this
<Books>
<Book>
<Title>Book1</Title>
<Price>10.00</Price>
</Book>
<Book>
<Title>Book2</Title>
<Price>15.00</Price>
</Book>
</Books>
Here is the problem, how to feed a xml formatter a correct input array like
[
'books' => [
'book' => [
'title' => 'book1',
'price' => 10.00,
],
'book' => [
'title' => 'book2',
'price' => 15.00,
]
]
You can't have same keys in an array! I really don't know what to do, please help.
When you attempt to export from any type to csv, if the content contains a comma the returned csv content is wrong.
XML rss feed requires rss tag
https://support.google.com/merchants/answer/160589?hl=en
Is there a way to add it without manipulating the XML post creation?
I'm trying to import an iTunes podcast feed but the iTunes specific tags are being ignored and are not included in the resulting array.
Here's an example of a feed: http://rss.earwolf.com/how-did-this-get-made
All the tags with "itunes:something" are missing from the generated array.
I'd be really grateful for any suggestions you might have on fixing this?
There is one thing I am bad at, and that is writing test cases!
I need to add some. I'll try to do that soon.
I am running into an issue where there is a comma within a cell but it is properly enclosed in a quotation marks.
https://github.com/SoapBox/laravel-formatter/blob/master/src/Parsers/CsvParser.php#L18
However, due to the setEnclosure being hardcoded to a pipe character, the parsing is breaking and ignoring the enclosure.
I propose allowing users of this package to simply define the enclosure to be whatever they need.
Hello,
Would you please create a release for your formatter? We have had trouble in the past with using dev-master in our composer file, so it would be great if you could create a release. That way we know we are always including a verison that will work for us.
Hi.
I need to convert array to xml without xml header declaration. How it do?
Supporting xml namespace at parsing to json
If xml likes:
<urlset content_method="full">
<url>
<loc>http://www.example.com/a.html</loc>
<desc>a.html</desc>
</url>
<url>
<loc>http://www.example.com/b.html</loc>
<desc>b.html</desc>
</url>
</urlset>
Then, the array is ?
Laravel6.0 not support
- soapbox/laravel-formatter 3.1.1 requires illuminate/support ~5.5
https://packagist.org/packages/soapbox/laravel-formatter
requires
illuminate/support: ~5.5
When you have a string value such as "12E389532" (a serial number in my case), json_encode tries to encode it as a number (because it sees the "E" in it and thinks it is in scientific notation). Because of the JSON_NUMERIC_CHECK flag that is set in Formatter, it chokes.
Would recommend removing it for PHP 5.3 or lower, and for PHP 5.4 or higher, perhaps this would be better:
return $pretty ? static::pretty_json($data) : json_encode($data, JSON_NUMERIC_CHECK | JSON_BIGINT_AS_STRING);
hi, i cant the 2.2 version, in packagist dont see that version
Can be expected version for Laravel 5 version?
When converting an array to XML, the package seems to add an extra XML tag.
$this->Report = array(
"Service" => array(
"ID" => $serviceID,
Is coming out with an XML open and close tag around the array.
How can I convert without this being added?
Invalid argument supplied for foreach()
The JSON seems fine. Could the problem be in that there is an key which value is an object of objects? It works otherwise if I leave that key out.
UPDATE: The same JSON outputs as XML without errors!
Can Output this kind of XML
<markers> <marker name="Pan Africa Market" address="1521 1st Ave, Seattle, WA" lat="47.608940" lng="-122.340141" type="restaurant" /> <marker name="Buddha Thai & Bar" address="2222 2nd Ave, Seattle, WA" lat="47.613590" lng="-122.344391" type="bar" /> </markers>
Source is (Array or Laravel Query).
use SoapBox\Formatter\Formatter;
use SoapBox\Formatter\Parsers\ArrayParser;
$xml = '<request_id>1234444</request_id><error_no>H000011-0003</error_no><error_type>2</error_type><error_no/><error_msg/><error_msg>auth error!</error_msg>';
$formatter = Formatter::make($xml, Formatter::ARR);
$array = $formatter->toArray();
print_r($array);
///////////////////////
output:
unserialize(): Error at offset 0 of 199 bytes
Using version ^3.0 for soapbox/laravel-formatter
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for soapbox/laravel-formatter ^3.0 -> satisfiable by soapbox/laravel-formatter[3.0].
- Conclusion: remove laravel/framework v5.6.3
- Conclusion: don't install laravel/framework v5.6.3
- soapbox/laravel-formatter 3.0 requires illuminate/support 5.5.x -> satisfiable by illuminate/support[v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34].
- don't install illuminate/support v5.5.0|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.16|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.17|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.2|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.28|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.33|don't install laravel/framework v5.6.3
- don't install illuminate/support v5.5.34|don't install laravel/framework v5.6.3
- Installation request for laravel/framework (locked at v5.6.3, required as 5.6.*) -> satisfiable by laravel/framework[v5.6.3].
Tags and content are confused.
source XML:
<?xml version="1.0" encoding="UTF-8"?>
<!--Anagrafica del clienti del mercato-->
<anagrafica>
<testata>
<nomemercato id="007">Mercato di test</nomemercato>
<data>Giovedi 18 dicembre 2003 16.05.29</data>
</testata>
<record>
<codice_cliente>5</codice_cliente>
<rag_soc>Miami American Cafe</rag_soc>
<codice_fiscale>IT07654930130</codice_fiscale>
<indirizzo tipo="casa">Viale Carlo Espinasse 5, Como</indirizzo>
<num_prodotti>13</num_prodotti>
</record>
<record>
<codice_cliente>302</codice_cliente>
<rag_soc>Filiberto Gilardi</rag_soc>
<codice_fiscale>IT87654770157</codice_fiscale>
<indirizzo tipo="ufficio">Via Biancospini 20, Messina</indirizzo>
<num_prodotti>8</num_prodotti>
</record>
<record>
<codice_cliente>1302</codice_cliente>
<rag_soc>Eidon</rag_soc>
<codice_fiscale>IT887511231</codice_fiscale>
<indirizzo tipo="ufficio">Via Bassini 17/2, Milano</indirizzo>
<num_prodotti>18</num_prodotti>
</record>
<record>
<codice_cliente>202</codice_cliente>
<rag_soc>SkillNet</rag_soc>
<codice_fiscale>IT887642131</codice_fiscale>
<indirizzo tipo="ufficio">Via Chiasserini 11A, Milano</indirizzo>
<num_prodotti>24</num_prodotti>
</record>
<record>
<codice_cliente>12</codice_cliente>
<rag_soc>Eidon</rag_soc>
<codice_fiscale>IT04835710965</codice_fiscale>
<indirizzo tipo="casa">Via Cignoli 17/2, Roma</indirizzo>
<num_prodotti>1112</num_prodotti>
</record>
<record>
<codice_cliente>5</codice_cliente>
<rag_soc>Miami American Cafe</rag_soc>
<codice_fiscale>IT07654930130</codice_fiscale>
<indirizzo tipo="casa">Viale Carlo Espinasse 5, Como</indirizzo>
<num_prodotti>13</num_prodotti>
</record>
<record>
<codice_cliente>302</codice_cliente>
<rag_soc>Filiberto Gilardi</rag_soc>
<codice_fiscale>IT87654770157</codice_fiscale>
<indirizzo tipo="ufficio">Via Biancospini 20, Messina</indirizzo>
<num_prodotti>8</num_prodotti>
</record>
<record>
<codice_cliente>1302</codice_cliente>
<rag_soc>Eidon</rag_soc>
<codice_fiscale>IT887511231</codice_fiscale>
<indirizzo tipo="ufficio">Via Bassini 17/2, Milano</indirizzo>
<num_prodotti>18</num_prodotti>
</record>
<record>
<codice_cliente>202</codice_cliente>
<rag_soc>SkillNet</rag_soc>
<codice_fiscale>IT887642131</codice_fiscale>
<indirizzo tipo="ufficio">Via Chiasserini 11A, Milano</indirizzo>
<num_prodotti>24</num_prodotti>
</record>
<record>
<codice_cliente>202</codice_cliente>
<rag_soc>SkillNet</rag_soc>
<codice_fiscale>IT887642131</codice_fiscale>
<indirizzo tipo="ufficio">Via Chiasserini 11A, Milano</indirizzo>
<num_prodotti>24</num_prodotti>
</record>
<record>
<codice_cliente>12</codice_cliente>
<rag_soc>Eidon</rag_soc>
<codice_fiscale>IT04835710965</codice_fiscale>
<indirizzo tipo="casa">Via Cignoli 17/2, Roma</indirizzo>
<num_prodotti>1112</num_prodotti>
</record>
</anagrafica>
result XML after XML -> CSV -> XML:
<?xml version="1.0" encoding="utf-8"?>
<xml>
<item>
<testata>
<nomemercato>Mercato di test</nomemercato>
<data>Giovedi 18 dicembre 2003 16.05.29</data>
</testata>
<record>
<item>
<codice_cliente>5</codice_cliente>
<rag_soc>Miami American Cafe</rag_soc>
<codice_fiscale>IT07654930130</codice_fiscale>
<indirizzo>Viale Carlo Espinasse 5</indirizzo>
<num_prodotti> Como</num_prodotti>
</item>
<item>
<codice_cliente>13</codice_cliente>
<rag_soc>302</rag_soc>
<codice_fiscale>Filiberto Gilardi</codice_fiscale>
<indirizzo>IT87654770157</indirizzo>
<num_prodotti>Via Biancospini 20</num_prodotti>
</item>
<item>
<codice_cliente> Messina</codice_cliente>
<rag_soc>8</rag_soc>
<codice_fiscale>1302</codice_fiscale>
<indirizzo>Eidon</indirizzo>
<num_prodotti>IT887511231</num_prodotti>
</item>
<item>
<codice_cliente>Via Bassini 17/2</codice_cliente>
<rag_soc> Milano</rag_soc>
<codice_fiscale>18</codice_fiscale>
<indirizzo>202</indirizzo>
<num_prodotti>SkillNet</num_prodotti>
</item>
<item>
<codice_cliente>IT887642131</codice_cliente>
<rag_soc>Via Chiasserini 11A</rag_soc>
<codice_fiscale> Milano</codice_fiscale>
<indirizzo>24</indirizzo>
<num_prodotti>12</num_prodotti>
</item>
<item>
<codice_cliente>Eidon</codice_cliente>
<rag_soc>IT04835710965</rag_soc>
<codice_fiscale>Via Cignoli 17/2</codice_fiscale>
<indirizzo> Roma</indirizzo>
<num_prodotti>1112</num_prodotti>
</item>
<item>
<codice_cliente>5</codice_cliente>
<rag_soc>Miami American Cafe</rag_soc>
<codice_fiscale>IT07654930130</codice_fiscale>
<indirizzo>Viale Carlo Espinasse 5</indirizzo>
<num_prodotti> Como</num_prodotti>
</item>
<item>
<codice_cliente>13</codice_cliente>
<rag_soc>302</rag_soc>
<codice_fiscale>Filiberto Gilardi</codice_fiscale>
<indirizzo>IT87654770157</indirizzo>
<num_prodotti>Via Biancospini 20</num_prodotti>
</item>
<item>
<codice_cliente> Messina</codice_cliente>
<rag_soc>8</rag_soc>
<codice_fiscale>1302</codice_fiscale>
<indirizzo>Eidon</indirizzo>
<num_prodotti>IT887511231</num_prodotti>
</item>
<item>
<codice_cliente>Via Bassini 17/2</codice_cliente>
<rag_soc> Milano</rag_soc>
<codice_fiscale>18</codice_fiscale>
<indirizzo>202</indirizzo>
<num_prodotti>SkillNet</num_prodotti>
</item>
<item>
<codice_cliente>IT887642131</codice_cliente>
<rag_soc>Via Chiasserini 11A</rag_soc>
<codice_fiscale> Milano</codice_fiscale>
<indirizzo>24</indirizzo>
<num_prodotti>202</num_prodotti>
</item>
</record>
</item>
</xml>
Parser.php ==> toCsv():
foreach ($result as $row) {
if ($count != 0) {
$output .= "\r\n";
}
$count++;
$output .= implode(',', $row); // <== crashes on 2-nd iteration.
}
[Catchable fatal error] Object of class stdClass could not be converted to string
Source.json
{
"testata": {
"nomemercato": "Mercato di test",
"data": "Giovedi 18 dicembre 2003 16.05.29"
},
"record": [{
"codice_cliente": "5",
"rag_soc": "Miami American Cafe",
"codice_fiscale": "IT07654930130",
"indirizzo": "Viale Carlo Espinasse 5, Como",
"num_prodotti": "13"
}, {
"codice_cliente": "302",
"rag_soc": "Filiberto Gilardi",
"codice_fiscale": "IT87654770157",
"indirizzo": "Via Biancospini 20, Messina",
"num_prodotti": "8"
}, {
"codice_cliente": "1302",
"rag_soc": "Eidon",
"codice_fiscale": "IT887511231",
"indirizzo": "Via Bassini 17\/2, Milano",
"num_prodotti": "18"
}, {
"codice_cliente": "202",
"rag_soc": "SkillNet",
"codice_fiscale": "IT887642131",
"indirizzo": "Via Chiasserini 11A, Milano",
"num_prodotti": "24"
}, {
"codice_cliente": "12",
"rag_soc": "Eidon",
"codice_fiscale": "IT04835710965",
"indirizzo": "Via Cignoli 17\/2, Roma",
"num_prodotti": "1112"
}, {
"codice_cliente": "5",
"rag_soc": "Miami American Cafe",
"codice_fiscale": "IT07654930130",
"indirizzo": "Viale Carlo Espinasse 5, Como",
"num_prodotti": "13"
}, {
"codice_cliente": "302",
"rag_soc": "Filiberto Gilardi",
"codice_fiscale": "IT87654770157",
"indirizzo": "Via Biancospini 20, Messina",
"num_prodotti": "8"
}, {
"codice_cliente": "1302",
"rag_soc": "Eidon",
"codice_fiscale": "IT887511231",
"indirizzo": "Via Bassini 17\/2, Milano",
"num_prodotti": "18"
}, {
"codice_cliente": "202",
"rag_soc": "SkillNet",
"codice_fiscale": "IT887642131",
"indirizzo": "Via Chiasserini 11A, Milano",
"num_prodotti": "24"
}, {
"codice_cliente": "202",
"rag_soc": "SkillNet",
"codice_fiscale": "IT887642131",
"indirizzo": "Via Chiasserini 11A, Milano",
"num_prodotti": "24"
}, {
"codice_cliente": "12",
"rag_soc": "Eidon",
"codice_fiscale": "IT04835710965",
"indirizzo": "Via Cignoli 17\/2, Roma",
"num_prodotti": "1112"
}]
}
Hi,
I have timeseries data like:
[ [ 1417646511,4 ], [ 1417648041,3 ], [ 1417649181,1 ], ...
This exports as CSV without title row – how to add the title row?
0,1
1417646511,4
1417648041,3
1417649181,1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.