markdown 将非原始参数传递给Apex方法的问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 将非原始参数传递给Apex方法的问题相关的知识,希望对你有一定的参考价值。

**Lesson learned**: When you need to pass Lists, Maps, Objects – basically anything other than primitives – convert them to a String.

In my case, I was passing a List of Objects from my Lightning component to my Apex method. The error that I found in the debug log for my Apex method was:
```
FATAL_ERROR|System.UnexpectedException: null External entry point
```
What made it especially hard to debug this was that the error occurred deep in my Apex method and not when the Apex method first started or when the parameter was first used. Debug statements printed out the value of the parameter perfectly! It took me quite a while to figure out the cause of this error.

**The Solution:**

In your Lightning component, use JSON.stringify to convert your object to a String:
```
action.setParams({ strFilters : JSON.stringify(component.get("v.lstFilters")) });
```
In your Apex method, convert it back:
```
MyClass[] lstFilters = (List<MyClass>)System.JSON.deserializeStrict(strFilters, List<MyClass>.Class);
```

以上是关于markdown 将非原始参数传递给Apex方法的问题的主要内容,如果未能解决你的问题,请参考以下文章

将非标准评估参数传递给子集函数

c++ 函数:将非 const 参数传递给 const 引用参数

Python 仅将非 None 的参数传递给函数

如何将非硬编码参数传递给 Python 装饰器?

将非静态成员函数作为参数传递给另一个类中的成员函数

为啥我们将字符串数组作为参数传递给 main() 方法,为啥不传递任何集合类型或包装类型或原始类型?