How to use Moralis.Query.fromJSON?

I am having hard time understanding how to use the Moralis.Query.fromJSON method.

Below is an example code:

Moralis.Cloud.define("example", async (request) => {
  const exampleData = [
    { name: "Ram", email: "[email protected]", age: 23 },
    { name: "Shyam", email: "[email protected]", age: 28 },
    { name: "John", email: "[email protected]", age: 33 },

  const query = Moralis.Query.fromJSON("TestJsonObject", JSON.stringify(exampleData));


  const results = await query.find();

  return results;

But when I call this, I get the following:

Error: Invalid parameter for query: 0
    at handleError (RESTController.js?a0a1:435)

The reason why I need to use this is because I want to combine multiple classes, and the only way I found was to merge the objects (property) from each classes, convert to JSON, then put that JSON to Moralis.Query.fromJSON so I can do aggressions.


I do not recognize the fromJSON() method and as the name implies the parameter should be a json object, but are 2 strings…

Searching “fromJSON” here and in the Moralis docs does nothing return (only this topic).

For me the “Moralis.Query” is used in this way:

  const query = new Moralis.Query("exampleTable");
  query.equalTo("exampleField", request.object.get('exampleParam'));
  const queryResults = await query.find({useMasterKey:true});  

This helps?

There may be possible to do aggregations from multiple classes (, I am thinking that you could also create another temporary table with the data that you want to agregate. I didn’t find fromJSON in documentation.

If you look at moralis>types>index.d.ts line 812, you can find this function.

The parameters are name of the class (I think I can call it whatever I want) and json. If I put normal json object, it would give me different error:

Error: json.keys.split is not a function
    at handleError (RESTController.js?a0a1:435)


const query = new Moralis.Query("exampleTable");

will look for the existing table (exampleTable) from the dashboard.