I'm not 100% sure what is giving you problems but will try to offer up a solution that will hopefully get you on your way.
There is an open source project on GitHub called MLJSON (https://github.com/marklogic/mljson/wiki). It can take a JSON string, parse it and return an XML document that MarkLogic can easily make use of.
If understanding the internal structure of the XML isn't appealing (even though it is fairly straightforward, it is undocumented), the project also includes a path parser to extract bits out of the parsed JSON document. Here's a quick sample XQuery page that will take some JSON sent to the server as a POST or GET parameter, parse it and pull out a value:
xquery version "1.0-ml";
import module namespace json="http://marklogic.com/json" at "lib/json.xqy";
import module namespace path="http://marklogic.com/mljson/path-parser" at "lib/path-parser.xqy";
let $jsonString := xdmp:get-request-field("json")
let $jsonXML := json:parse($jsonString)
let $firstName := path:select($jsonXML, "author.firstName", "json")
return concat("First name: ", $firstName)
If the above script is passed a JSON document like:
{
"author": {
"firstName": "Noam",
"lastName": "Chomsky"
}
}
It will return the string: "First name: Noam".
MLJSON has a number of other features that I won't go over here, but will mention that it has functions to construct JSON objects, arrays, etc and serialize them out as a JSON string.
Hope that helps.