How can I load a json model on serverside? When I use ObjectLoader to parse json, it give me a prompt message as following.
ReferenceError: window is not defined
at ObjectLoader.parseGeometries (\node_modules\three\build\three.js:39019:24)
at ObjectLoader.parse (\node_modules\three\build\three.js:38716:26)
Related
I have been trying to call fields from a csv file by using some piece of code that I have obtained from d3.js in Observablehq. For some reason I keep getting this error that the field or variable is undefined but I have actually loaded the csv file. The only strange part could be that these fields are using dots in their names. I am not sure if that is the reason why I am not able to use or call these fields from the CSV. Any leads?
For example in the following image I am getting the error when trying to call Mission.Year:
I have written below code in Mail/Mails.php file build function.
return $this->from(config('app.FROM_EMAIL'),config('app.MAIL_FROM_NAME'))
->subject($this->subject)
->view('emails.generalmail')
->attachData($this->attach,'file_pdf.pdf');
Error
Unable to JSON encode payload. Error code: 5
I used Dompdf email send with attachment.
You can do it without saving the file to disk using the function
->attachData($this->attach,'file_pdf.pdf'). The error is thrown because php doesnt know how to serialize the binary pdf file data to json. What you need to do is generate the data $this->attach in your mail files handle function, not the constructor. That way php doesnt have to serialize it:
```
public function handle() {
$pdf = PDF::loadView('pdf_view', $data);
return $this->from(config('app.FROM_EMAIL'),config('app.MAIL_FROM_NAME'))
->subject($this->subject)
->view('emails.generalmail')
->attachData($pdf->output(),'file_pdf.pdf');
}```
I'm not sure what version of Laravel you are on so it could be slightly different but you need to use the attach function rather than attachData
return $this->from(config('app.FROM_EMAIL'),config('app.MAIL_FROM_NAME'))
->subject($this->subject)
->view('emails.generalmail')
->attach('[PATH TO FILE]');
See more here: Laravel Mail Docs
Change the version at the top.
I am using Lumen + Dingo + Ember JS
I am able to transform the response into JSON API. But when I post back the data from Ember, is it in same json api format. So I want to know is there any way to deform the json api data ?
data":{"attributes":{"size":2},"relationships":{"page":{"data":{"type":"pages","id":"2"}}},"type":"rows"}}
From above response, i want to get `size=2, pageId=2
I have properly used relationship in Lumen models.
Any idea, how can I achieve this?
P.s The question is about deformation of data from json api format, but not about json encode/decode.
if you are trying to decode in javascript then
JSON.parse(jsonString) // where jsonString is your string this will return parsed object in javascript
if you are trying to decode in php then
json_decode(jsonString) // will give you stdClass object
I'm writing a Joomla 2.5 or 3.x component
which make data elaboration and returns some data.
I want that work as a service that is invoked and returns data
(eg
I call www.mysite.com?option=com_mycomponent&view=myview
and result for example my json data ..or xml or what i need after my elaboration
)
so i need that my output view is raw.
i need no template and no css or js..
only my result..
but now the results are inserted into the template
Is it possible?...
I tried to create a RAW mode in my template
like Here .
this works but is not what I want
but it is a dirty solution
because it work if the url i have to call is like ...
www.mysite.com~....~&tmpl=raw
I'd like my component can output as raw.
Thanks
Create RAW view views/[myview]/view.raw.php inside your component
In requests require RAW format
index.php?option=com_mycomponent&view=myview&format=raw.
Like in com_banners/views/tracks/view.raw.php.
Sames goes for JSON and XML.
Here's a list of generic document formats: libraries/joomla/document
feed
html
image
json
opensearch
raw
xml
To use JSON format in response, I recommend new JResponseJson class:
// Anything that may be serialized with json_encode or an Exception
$data = array('some' => 'data');
echo new JResponseJson($data);
I am using a SOAP API that returns XML but with JSON strings within the response envelope. For most of the API calls this has not been a problem but there is one that returns Javascript new Date objects that is causing problems when using JSON.parse. Here is a simplified example of the response I am getting.
"{\"History\":[ {\"Timestamp\":new Date(1380024020923)}]}"
When using JSON.parse I get the following error.
JSON::ParserError: 399: unexpected token at '{"Timestamp":new Date(1380024020923)}]}'
Is there a nice way to parse this string or am I going to have to use some regex/string trickery? Has anyone come across this way of returning a date object and I would like to understand the advantage?