I am trying to create custom metadata from Apex test class. I have used this solved question as a reference and tried to create the same. But when I try to run the test method, I see the error as:

System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set

This is what I tried in my code:

 Mxx_hhhh.customMeta  = (List< Custom_Metadata__mdt>) JSON.deserialize({"Program_Id__c":"16"}, List< Custom_Metadata__mdt>.class );

Please let me know if there is any issue in this.

1 Answer 1


You are telling JSON.deserialize that the JSON is a list of objects (List< Custom_Metadata__mdt>) but the JSON string you are suppying represents only a single object.

The JSON for a list containing a single object is e.g.:


This json.org page explains the syntax of JSON - there is not a lot to it so its worth getting familiar with it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .