0

$.ajax({
type: "GET",
dataType: 'jsonp',
url: 'https://wiljcr.blogspot.com/feeds/posts/default/5158425934439969382?alt=json-in-script',
success: function(data) {
    var entry = data.entry;
    $(entry).each(function() {
        content = this.content.$t;
        myArray = {};
        $.each($(content), function() {
            var getClass = $(this).attr('class');
            myArray[getClass] = $(this).find("li").map(function() {
                return $(this).text();
            }).get()
        });
        console.log(myArray);
    });
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Current output, after countless trial n error:

{
    am: ["gud am", "good morning"],
    greetings: ["hi", "hello", "hey"]
}

Desired output:

[
    am = ["gud am", "good morning"],
    greetings = ["hi", "hello", "hey"]
]

Thanks for your help...

5
  • @freedomn-m [ am = ["gud am", "good morning"], greetings = ["hi", "hello", "hey"] ] is not the output of that Commented Sep 27, 2020 at 9:28
  • @mplungjan yes, coming to that conclusion... [ am = [ isn't a multi-dimensional array Commented Sep 27, 2020 at 9:29
  • @mplungjan Added an answer with some working snippets, but it won't give OPs exact requirement as, like you say, it's not quite js. Commented Sep 27, 2020 at 9:31
  • So myArray=[]; using myArray.push($(this).find("li").map(function() {$(this).text()}).get()) is the closest you can come using array Commented Sep 27, 2020 at 11:30
  • @mplungjan, your solution works fine on my project, thanks! pls add it as an answer so i can select it. Commented Sep 28, 2020 at 18:09

1 Answer 1

1

The closest you can get would be

myArray=[];
myArray.push($(this).find("li").map(function() {$(this).text()}).get());
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.