I'm using Parse Server as a back end (the open source version). I have an Android application that saves an object to the server's DB. The object is simply a key-value pair. When the Android application creates an object, it creates it as JSON object.
Now I want to retrieve the same object from an Ionic 2 app. In Ionic, I use the JS Parse API to access the back end. When an object is created in the JS API, it's created as a plain text object.
As a result I'm getting: 101 Object not found
It seems like what I need to do is to translate Parse plain text object to Parse JSON object.
This is what I tried to do:
According to the JS Parse documentation one of the methods of Parse.Object is toJSON(). I tried to apply this method in different combinations to the Parse object before creating query, but I always get an error: this.parse.Object.extend(...).toJSON is not a function
I tried to apply standard JSON Api (i.e. JSON.stringify) to the Parse object. In this case I'm getting an error: ParseQuery must be constructed with a ParseObject or class name.
I did very extensive search on internet and found nothing helpful.
Would appreciate any ideas on the matter.
Figured it out. The problem was corrupted disk on the server side. Created new server and new DB and everything works fine now.
Related
Hey friends, so what happened is I developed a rest API using Nodejs Express and Mysql, It is working fine on my local machine, I then hosted it on Cpanel, now I am trying to fetch data from it and render it on my react app. Well fetching the data part works like magic, its even rendering in my console, but when I map the data on my react app it is giving the error below, and just a blank white page. May you please assist .
If the data object is still in a nested object (aka JSON) format, then using .map() on it won't work, as .map() is not a function for Objects.
Try converting data to an array of objects then use .map().
You can grab all the values with Object.values and push into an array that you can map
I'm testing for some software analytics and I need to send GET requests with geolocation object with variable timestamps and locations. The site uses HTML5 navigator.getcurrent.location().
I can use random module to randomise locations & timestamps. However, the JSON object creation part is troubling me as the structure in documentation has null values and python dictionary doesn't accept it.
So, could you show me how to Just create an HTML5 Geolocation object in python which is ready to be sent via GET request?
I'm assuming you're using eval to parse your JSON because you said python doesn't accept the null keyword. Using eval on JSON is asking for trouble in any language. Python has a built in JSON parser. Use it!
import json
# put GET response in location_json_string
location_dict = json.loads(location_json_string)
To encode:
# Put your data in data_dictionary
request_json = json.dumps(data_dictionary)
# send GET request appending request_json to the URL
I have a JSON file which is dynamically and contain match info including an unique id. The JSON is divided into 3 arrays live, upcoming and recent. Since i'm quite new to Javascript i'm wondering what would be the best way to go in order to make this livescore script. I need it to be updating without refreshing browser? What is my options? Maybe someone has a snippet?
The JSON is automatically updates through another script which is connected to a cron job, so the script does not need to do anything regarding the JSON. Only retrieve and show the data.
I'm using dreamhost, which gives me access to shell, so websockets and so on is an option.
You'll need a jquery user to give you a snippit for this one, but in vanilla ecmascript 6, you use an XMLHttpRequest object to get the JSON from your server. This object can request data from the server asynchronously and is triggered by the client/browser so you can update the live match info when and as often as you like. You would just have to write a function to replace the data on the webpage with the new info when it is updated.
I have a list of of data being return from a "standard" HttpGet IQueryable method from an ApiController that implements the Breeze EFContextProvider. When one of the objects references another object that has already been returned in the payload, Breeze gives me an $ref to refer to the object that was already returned.
I want the object with all related objects return explicitly, not a reference with $ref. Also, I'm not using the breeze.js library on the client side; simply making straight calls to the Controller with a web address.
I found this:
Breeze does not replace the Ref: node with its real data
which is the thing I'm looking for, but using Include on the server still doesn't return all of the data.
Any idea on how to "force" Breeze on the server side to include all related data no matter if it was returned and referenced in the payload?
Update 1
Per Steve's answer below I added the following to the BreezeWebApiConfig.RegisterBreezePreStart method in the App_Start folder:
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.Object;
Compiling and running produces the same output with only the $ref group instead of the full data. I'm sending a request to the server to $expand the collection. Do I need to change the SerializerSettings upon each request to the controller or will adding this to the BreezeWebApiConfig.RegisterBreezePreStart method be enough?
Update 2
I've added a CustomBreezeConfig class per the instructions at the link that Steve added in his answer. I am however using Breeze.WebApi2 so it appears that the BreezeConfig is actually in Breeze.ContextProvider. The code compiles, but I'm still seeing the same $ref for the actual object in JSON.
Do I need to include this CustomerBreezeConfig class in a specific place in my project for Breeze to use it's serializer settings?
Under WebAPI, Breeze uses the Json.NET serializer to turn the results to JSON. You can change the serializer settings (specifically the PreserveObjectReferences setting) to change this behavior.
Breeze configures it's own JSON serializer, so in a Breeze app, you'll need to configure it as described in the Breeze Web API Controller doc.
Note that, if you turn PreserveObjectReferences off, you might also need to configure the ReferenceLoopHandling setting, if you have circular reference in your object graphs (as most of us do).
I need to pass a bunch of parameters to a web API method which returns a byte array that is needed to display a PDF report on a page. I tried doing this via a GET method but the query string is too long and it throws an exception. I have tried shortening the query string as much as physically possibly but it is still too long. All of the external PDF viewer libraries require a string path to the PDF. I need something that allows me to supply a string path and some parameters or just a string path but that uses a POST instead of a GET. I was thinking about POSTing the object values to the web API along with a GUID and storing it somehow on the server then with an tag calling another API method and retrieving the stored data by only passing the GUID as a parameter but I don't want to make a database table for only that to save and retrieve the data. I entertained the idea of saving the byte array to a PDF on the server and then simply pointing a PDF viewer to that after but I had no success with that either and that is not ideal.
File.WriteAllBytes(path, res);
The code above is the most common way I have found to save the file but when I open the new PDF file after it says it is corrupt and it won't allow me to open it. Ideally I would just find a method that allows me to POST data to my web API then embeds the result in a pdf.js/pdfObject/ control. Please help, this has stumped me for days. Thanks in advance!!