0

Is it possible to use the cursor class to expose a json object? I have a custom abstract cursor(param = json object) and find I can't override the abstract cursor moveToFirst/moveToNext to support iteration. Any pointers on how to keep the json format(no probs parsing the json) within the cursor without transforming it, would be great.

Thanks Alex

2
  • Is the JSON data in a single String? Is it a byte stream? Commented Jul 8, 2011 at 16:04
  • "Is it possible to use the cursor class to expose a json object?" Is it really a JSON object? Or is it a JSON array? What's the cursor supposed to do when it iterates? Move to the next token? the next element name/value pair? What if the next element value is a complex object or array? I can't figure out how this approach to handling JSON is desirable (or how it's supposed to work). What problem does it solve that's not more easily solved by just transforming the JSON into a Java data structure? Commented Jul 8, 2011 at 16:13

1 Answer 1

1

You can use MatrixCursor to return data that you have either in xml or json format.

MatrixCursor : A mutable cursor implementation backed by an array of Objects.

final MatrixCursor cursor = new MatrixCursor(SEARCH_COLUMN_NAMES);              
for (OpenSearchHandler.Result result : results) {                       
     cursor.addRow(new Object[] { result.id, result.title, result.description, result.url });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.