I am creating a array for posting candidate details to an API. that API accepts data in JSON format, I am creating a data for the API using PHP array and using JSON encode to convert it JSON array. but not able to get intended format
PHP Code
$postArray = array(
"DefaultCurrency" => "USD",
"UserName" => "data",
"Photograph" => "data",
"PhotographThumb" => "data",
"Group" => "data",
"Summary" => "data",
"ResumeText" => "data",
"RollupListMembership" => array(
"RollupCode" => "data"
),
"CustomFields" => array(
"FieldName" => "Major",
"Values" => array(
$finalResumeData-> "data"
),
"FieldName" => "Years of Experience",
"Values" => array(
$MonthsOfWorkExperience
),
"FieldName" => "Executive Type",
"Values" => array(
$finalResumeData-> "data"
),
)
);
If i run this code as it is its showing only last result of the CustomFields
I have tried using array() for individual CustomFields in the array like
"CustomFields" => array(
array("FieldName" => "Major",
"Values" => array(
$finalResumeData-> "data"
)),
I am getting the results as
CustomFields: {
"0": {
"FieldName" : "Value",
"Values": ["data"]
}
}
Intended result
"CustomFields": [
{
"FieldName": "string",
"FieldType": "string",
"Values": [
"string"
]
},
{
"FieldName": "string",
"FieldType": "string",
"Values": [
"string"
]
}
],
So what should I update in the PHP array to get intended results.
FieldNameandValues)."CustomFields" => array( array("FieldName" => "Major", "Values" => array( $finalResumeData-> "data" )),I am getting the results as 0, 1... keys but I want it to be{ "FieldName": "string", "FieldType": "string", "Values": [ "string" ] }json_encodecall?$putdata = stripslashes(json_encode($postArray));